You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backbone.history provides a property called fragment which is normally used to obtain the current fragment to, for example, build <a> links. I'd like to suggest backbone-query-parameters add to this by providing the current route/fragment and the current parameters as a separate property, ie.
The reason I'm suggesting this is because I have a method in my router called buildFragment that allows you to build a URL fragment based on the current params:
This allows me to build a URL by adding a parameter and preserving any existing ones I'd like to keep.
For my case, I'm setting the route and params property manually on every route, but it would seem like this should be set automatically. Let me know if you know of a better way to do this.
The text was updated successfully, but these errors were encountered:
Backbone.history
provides a property calledfragment
which is normally used to obtain the current fragment to, for example, build<a>
links. I'd like to suggestbackbone-query-parameters
add to this by providing the current route/fragment and the current parameters as a separate property, ie.#foo/bar?a=1&b=2
becomes{fragment: "foo/bar?a=1&b=2", route: "foo/bar", params: {a: 1, b: 2}}
The reason I'm suggesting this is because I have a method in my router called
buildFragment
that allows you to build a URL fragment based on the current params:,buildFragment: function(route, add, preserve) { var newParams = preserve !== undefined && preserve.length && this.params !== undefined ? _.extend(add, _.pick(this.params, preserve)) : add; return (route || this.route) + ( ! _.isEmpty(newParams) ? "?" + $.param(newParams) : ""); }
This allows me to build a URL by adding a parameter and preserving any existing ones I'd like to keep.
For my case, I'm setting the
route
andparams
property manually on every route, but it would seem like this should be set automatically. Let me know if you know of a better way to do this.The text was updated successfully, but these errors were encountered: