on the “update” callback you can get the order of elements with $(this).sortable('toArray');
But this order contains the element IDs.
How can I get a custom attribute, like data-myattr? I want that order to contain values from this attibute instead of IDs….
$('ul').sortable({
handle: 'h2'
items: 'li',
context: this,
update: function(){
var order = $(this).sortable('toArray');
// here I want a array of values from my attribute, not ID values...
alert(order);
....
}
});
The HTML is simple:
<ul>
<li data-myattr="a-1" id="whatever">
...
</li>
...
1 Answer