mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-24 14:27:56 -05:00
Adding Backbone.Router.setLocation, alongside saveLocation, to both save and route at once.
This commit is contained in:
10
backbone.js
10
backbone.js
@@ -578,8 +578,9 @@
|
||||
if (!model.collection) {
|
||||
model.collection = this;
|
||||
}
|
||||
var index = this.comparator ? this.sortedIndex(model, this.comparator) :
|
||||
options.at != null ? options.at : this.length;
|
||||
var index = options.at != null ? options.at :
|
||||
this.comparator ? this.sortedIndex(model, this.comparator) :
|
||||
this.length;
|
||||
this.models.splice(index, 0, model);
|
||||
model.bind('all', this._onModelEvent);
|
||||
this.length++;
|
||||
@@ -689,9 +690,8 @@
|
||||
},
|
||||
|
||||
// Simple proxy to `Backbone.history` to both save a fragment into the
|
||||
// history and to then load the route at that fragment. Used in place
|
||||
// of settings `window.location.hash` when using `window.history.pushState`.
|
||||
loadUrl : function(fragment) {
|
||||
// history and to then load the route at that fragment.
|
||||
setLocation : function(fragment) {
|
||||
Backbone.history.saveLocation(fragment);
|
||||
Backbone.history.loadUrl();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user