Sha256: cdbb8a6211bf8b0d5478c440f2d0bde17bcdbbd3fe4f794772b6758cf478a34c
Contents?: true
Size: 1.01 KB
Versions: 6
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('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
6 entries across 6 versions & 1 rubygems