Reputation: 1019
I have created a little autosuggest app with Backbone and it works in its own page (http://www.alexbarron.co.uk/bbExample). However when I integrate it into my website the this.model property of one of my collections is never being set. I have debugged it to this point and found that this is where the difference between the integrated version and the standalone version begins.
Script order on the 2 pages is the same.
To replicate:
function (){ return parent.apply(this, arguments); }
Any help would be appreciated.
Upvotes: 0
Views: 33
Reputation: 28
Problem is the order of downloading collection.js and model.js. I put a breakpoint in collection.js and model.js at first line, so that when the files are interpreted, the breakpoints are hit. collection.js was downloaded first and model is set as undefined, as model.js containing TreeCategoriesAutoSuggest.Models.Category is not downloaded yet :
TreeCategoriesAutoSuggest.Collections.Suggestions = TreeCategoriesAutoSuggest.Collections.SelectedCategories = Backbone.Collection.extend({
model: TreeCategoriesAutoSuggest.Models.Category
});
In index.html, change the order. Place model.js first and then collection.js as shown below.
<script type="text/javascript" src="/frontend/javascripts/projects/tree-categories-autosuggest/demos/backbone-js/models.js"></script>
<script type="text/javascript" src="/frontend/javascripts/projects/tree-categories-autosuggest/demos/backbone-js/collections.js"></script>
Upvotes: 1