Skip to content Skip to sidebar Skip to footer

Trying To Loop Through Collection In Backbone To Output Attributes In Dom

I recently updated my backbone js file to the newest version and what do you know stuff is breaking - so frustrating. I am instantiating a collection within a view and I'm trying

Solution 1:

In your NavigationItem definition, you set the default value for id to an empty string :

varNavigationItem=Backbone.Model.extend({defaults: {
        name:'',
        href:'',
        last:false,
        id:''
    }
});

In Backbone 0.9.9, models are added in reverse order and duplicate models are rejected, an empty string being accepted as a valid id, leaving you with your last model in your collection. Remove the default value for id to solve your problem

varNavigationItem=Backbone.Model.extend({defaults: {
        name:'',
        href:'',
        last:false
    }
});

Post a Comment for "Trying To Loop Through Collection In Backbone To Output Attributes In Dom"