Previously mentioned methods

Several methods in the preceding list should already be familiar, as we have already explained the each, map, invoke, pluck, and reduce methods in Chapter 2, Object-Oriented JavaScript with Backbone Classes. All these methods work the same if you call their Underscore version and then pass Collection.models to them, as shown here:

var cats = new Backbone.Collection([ 
    {name: 'Garfield'},    {name: 'Heathcliff'}
]);
cats.each(function(cat) {
    alert(cat.get('name'));
}); // will alert "Garfield", then "Heathcliff"
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.46