johnny / jquery-sortable

A flexible, opinionated sorting plugin for jQuery
http://johnny.github.io/jquery-sortable/
Other
1.52k stars 441 forks source link

There Doesn't Seem to be a Way to Update Sortable Options After Init #214

Open homestar9 opened 8 years ago

homestar9 commented 8 years ago

FYI this is easily the best sortable plugin I've found for adding drag and drop support for tables. Nice job!

Only thing I noticed during my tests is that there is no way to update the sortable options after it has been initialized. For example, a user might want to update the serialize function after initialization.

// initialize the sorting on a table
$('.myTable').sortable({
     containerSelector: 'table',
     itemPath: '> tbody',
     itemSelector: 'tr',
     placeholder: '<tr class="placeholder"/>',
     serialize: function(parent, children, isContainer) {
          return isContainer ? children.join() : $('input[name="ID"]', parent).val();
}

// update serialize
$('.myTable').sortable("option", "serialize", function(parent, children, isContainer) {
     console.log('hi there');
});

Did I miss how to do this in the documentation somewhere? Currently the only way I can think of to update it is to destroy sortable and re-init.

GerkinDev commented 7 years ago

Interested to see that too