-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added params.backbutton #20
base: master
Are you sure you want to change the base?
Conversation
Not sure if scrolling should be part of Derby (built-in)? |
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this should have a null check (if this.options)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 [email protected]
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#L76https://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
How about this? ^---check if options exists |
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)
.