Sha256: b1fb3c82ec3b6ad31e3b9462886e9f572971d598bec001e2c0f56f7dabc524af
Contents?: true
Size: 969 Bytes
Versions: 12
Compression:
Stored size: 969 Bytes
Contents
pageflow.orderedCollection = { initialize: function() { 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('patch', 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
12 entries across 12 versions & 1 rubygems