Pollux Khafra
Pollux Khafra

Reputation: 862

Bind a function to get the class of a sortable item

I'm using Jquery UI Sortable to interchange items from two lists. I need to get the class from an item when it is moved from one list to another which is easy enough to do like this.

$("#sortable").sortable({
    update: function (event, ui) {
            alert($(ui.item).attr('class'));
        }
});

But I need to do this on dynamic content so I need to to bind this function with .on to make it work. So how I can do something like this..

$(document).on("sortable","#sortable", function() {

and still access the api update option to make this work?

Upvotes: 1

Views: 222

Answers (1)

joao
joao

Reputation: 342

i think you should check http://api.jqueryui.com/sortable/ ,the events tag. i took this example for there:

$( ".selector" ).sortable({
    sort: function( event, ui ) {
          //do stuff
     }
});

This event is triggered during sorting, you can also bind events on stop, before stop and start, check it.

Upvotes: 0

Related Questions