There's no documentation for Backbone.history.loadURL on backbone.js website http://backbonejs.org/#History-start Although I have a general idea what result it produces in some applications I've looked at, I'm not exactly sure how it works, in the sense of which url it chooses to load and how it knows to load a certain url over another. Can anyone explain?
$.ajax({
url: "json/Backboneapp_data.json",
dataType: 'json',
data: {},
async: false,
success: function (data)
{
_this._data = data;
_this._items = new ItemCollection(data);
_this._view = new MenuView({ model: _this._items });
_this._view.render();
Backbone.history.loadUrl();
}
});
Notes on loadUrl
from the Annotated Source:
Attempt to load the current URL fragment. If a route succeeds with a match, returns true. If no defined routes matches the fragment, returns false.
So, if the current URL fragment (or the one you pass as a parameter) is valid, then it invokes route
. Note also that the function returns true if it resolved a valid route based on the fragment, otherwise false.
If it helps clarify: look down in the source, and you'll notice that loadUrl
is what navigate
calls if you specify the option trigger:true
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With