Created
April 5, 2012 13:01
-
-
Save destroytoday/2310892 to your computer and use it in GitHub Desktop.
Backbone.js facepalm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppRouter extends Backbone.Router | |
routes: | |
'users/:user': user | |
user: (user) -> | |
console.log 'navigated to user:', user | |
router = new AppRouter | |
Backbone.history.start { pushState: true } | |
# This changes the URL, but does NOT trigger the AppRouter.user function: | |
router.navigate 'users/destroytoday' | |
# This changes the URL and triggers the function: | |
router.navigate 'users/destroytoday', true | |
# This also works: | |
router.navigate 'users/destroytoday', { trigger: true } | |
# In my opinion, trigger should be true by default. Why would you want to change the URL without doing anything? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"Why would you want to change the URL without doing anything?"
You could have tabs or a carousel with all the data loaded in the page and use different urls to have different states.
Then you have a unique url for each tabs or carousel item.