lib/assets/javascripts/transistor-backbone.js in transistor-0.1.11 vs lib/assets/javascripts/transistor-backbone.js in transistor-0.1.12

- old
+ new

@@ -5,11 +5,11 @@ } (function (transistor) { var BackboneCollection = (function () { return function (options) { - var Backbone, U, channel, radio, control, H, backbone_collection, collection_interface, control_interface, binder; + var Backbone, U, channel, radio, control, H, backbone_collection, collection_interface, control_interface, binder, set; Backbone = options.backbone; U = options.underscore; channel = options.channel; radio = options.radio; @@ -78,21 +78,29 @@ delegate('remove'); delegate('reset'); delegate('set'); }(backbone_collection)); - binder = transistor.Binder({ - set: function (collection) { - collection_interface.asPublic(function () { - var models = [], i; + set = function (collection) { + collection_interface.asPublic(function () { + var models = [], i; - for (i = 0; i < collection.length; i += 1) { - models.push(new Backbone.Model(collection[i])); - } + for (i = 0; i < collection.length; i += 1) { + models.push(new Backbone.Model(collection[i])); + } - backbone_collection.set(models); - }); + backbone_collection.set(models); + }); + }; + + binder = transistor.Binder({ + init: function (collection) { + set(collection); + if (options.on_init !== undefined) { + options.on_init(backbone_collection); + } }, + set: set, insert: function (entry) { collection_interface.asPublic(function () { backbone_collection.add(new Backbone.Model(entry)); }); },