Added params.backbutton

I needed a way to detect if the page was rendered by the user pressing the back button. In case it was, I didn't do anything, but in case it was rendered "normally" (clicking a link), I called `window.scrollTo(0,0);` to scroll the page to the top. This is the way it usually works I believe (on the web without Derby) - the page is scrolled to the top.

So, this feature adds `params.backbutton = true` to the route callbacks `(page, model, params, next)`.
We prefer to have null checks because it can crash a process if you forget
it. Options are usually optional, so making sure there is a reasonable
response when the options are missing is preferred.


On Thu, Aug 7, 2014 at 11:41 PM, Ilkka Huotari <notifications@github.com>
wrote:

> In lib/router.js:
>
> > @@ -137,5 +137,6 @@ RenderReq.prototype.routeParams = function(route) {
> >    params.body = this.body
> >    params.query = this.query
> >    params.method = this.method
> > +  params.backbutton = this.options.backbutton
>
> Yes, perhaps, but it seemed like options would always have a value (an
> object).
>
> called here
> https://github.com/ilkkah/tracks/blob/feature-backbutton/lib/router.js#L30
> and here:
> https://github.com/ilkkah/tracks/blob/feature-backbutton/lib/History.js#L46
> https://github.com/ilkkah/tracks/blob/feature-backbutton/lib/History.js#L76
>
> https://github.com/ilkkah/tracks/blob/feature-backbutton/lib/History.js#L217
>
> https://github.com/ilkkah/tracks/blob/feature-backbutton/lib/History.js#L228
>
> But I'm not sure if it's is called from other modules. I quickly checked
> but couldn't find anything.
>
> Should I add the check? It's ok to me. Not sure what your practice is here
> (how strict).
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/derbyjs/tracks/pull/20/files#r15979820>.
>



-- 
Ian Johnson - 周彦
http://enja.org