Skip to content

Instantly share code, notes, and snippets.

@OscarGodson
Created November 13, 2013 17:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OscarGodson/239bc11a4e8c2b46faad to your computer and use it in GitHub Desktop.
Save OscarGodson/239bc11a4e8c2b46faad to your computer and use it in GitHub Desktop.

I have a sidebar that pops in with form. It has a URL for it since it's so commonly used. Going to app.com/foo/add would load the page and open the sidebar. Another view, TopMenu, has a button to open the sidebar. My question: who triggers the URL change? Should RightSidebar change the URL with Backbone.navigate (w/o trigger) or should the button change the URL and call the RightSidebar's open method?

@techwraith
Copy link

If it has a route, why not just navigate to that route and have the route handle the opening and closing?

@OscarGodson
Copy link
Author

@techwraith you mean like app.router.navigate('foo/add', {trigger: true})? I've read all over trigger is bad and causes issues. @derickbailey has written about it a few times.

If you simply mean make an html link to foo/add, that would work as it is now, but causes a full page refresh since it's pushState, not hashes. If you mean navigate minus the trigger, this would just change the URL and the app would ignore this.

If you mean something other than those three things or a way to make it better, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment