Langel
Langel

Reputation: 325

jQuery sortable - disable single item

I have a few lists with draggable elements. When the user moves any element to a new place $.ajax is called so the server can record the element's change in position. While I can disable sorting for the whole list, I really only want to disable sorting for the moved element until $.ajax receives a success message.

update: function(event, ui) {
  ui.item.sortable('disable');
  $.ajax({options}, success: function() {
    ui.item.sortable('enable');
  });
}

I've done a lot of research so far, and can only get the whole list to disable. Any suggestions to what I'm doing wrong, or is this not possible?

Upvotes: 2

Views: 2682

Answers (1)

Langel
Langel

Reputation: 325

Sortable's cancel setting allows you to cancel sortable calls using selectors. I added the following line --

cancel:'.updating'

...and then I add and remove the class around the $.ajax call.

I don't know how I had missed this all day yesterday. :D/

Upvotes: 3

Related Questions