From e5ee5503fd388b7fd6efccef829545e0af7b047b Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Thu, 26 May 2011 12:02:12 -0400 Subject: [PATCH] Adding Backbone.Router.setLocation, alongside saveLocation, to both save and route at once. --- backbone.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backbone.js b/backbone.js index 6cfffd31..ea8095f7 100644 --- a/backbone.js +++ b/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(); },