Sha256: a9d2e1218b813194fd05806172e91f5586f415a086b97c691f2c7e5916ec8b79

Contents?: true

Size: 707 Bytes

Versions: 1

Compression:

Stored size: 707 Bytes

Contents

(function($) {

  $.fn.railsSortable = function(options) {
    options = options || {};
    var setting = $.extend({
      axis: 'y',
      scroll: 'true',
    }, options);

    setting.update = function(event, ui) {
      if (typeof options.update === 'function') {
        options.update(event, ui);
      }
      $.post("/sortable/reorder", makePostData($(this)));
    }

    this.sortable(setting);
  };

  var makePostData = function($sortable) {
    var data = {}, klass, id;
    $sortable.sortable('toArray').forEach(function(sortableId) {
      [klass, id] = sortableId.split(/[-=_]/);
      (data[klass] || (data[klass] = [])).push(id);
    });
    return { rails_sortable: data };
  };
})(jQuery);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_sortable-1.1.4 vendor/assets/javascripts/plugin.js