Sha256: 10e68080dc3f84fae8981b66440d4693725929d8a93739cc0c624989b8a2b363
Contents?: true
Size: 1.01 KB
Versions: 58
Compression:
Stored size: 1.01 KB
Contents
pageflow.orderedCollection = { initialize: function() { if (this.autoConsolidatePositions !== false) { this.listenTo(this, 'remove', function() { this.consolidatePositions(); this.saveOrder(); }); } }, consolidatePositions: function() { this.each(function(item, index) { item.set('position', index); }); }, saveOrder: function() { var parentModel = this.parentModel; var collection = this; if (collection.isEmpty()) { return $.Deferred().resolve().promise(); } return Backbone.sync('update', parentModel, { url: collection.url() + '/order', attrs: {ids: collection.pluck('id')}, success: function(response) { parentModel.trigger('sync', parentModel, response, {}); parentModel.trigger('sync:order', parentModel, response, {}); }, error: function(jqXHR, textStatus, errorThrown) { pageflow.editor.failures.add(new pageflow.OrderingFailure(parentModel, collection)); } }); } };
Version data entries
58 entries across 58 versions & 1 rubygems