javascript - Sortable - Excluded items still affect index -
i have sortable set this:
$('.sortable').sortable({ items: '> *:not(.nosort)', axis: 'y', stop: function (event, ui) { var index = ui.item.index(); // index } });
i want ignore elements nosort
class sortable.
this works good; however, index seems include elements in sortable, not can sorted, can't used need.
is there easy way avoid this?
here's jsfiddle of example sortable.
(note: subtracting 1 index not option, because number , position of excluded elements can vary)
get collection of .sortable
children , find index, using .index()
, based on that...
you can making following changes:
$(document).ready(function () { $('.sortable').sortable({ items: '> *:not(.nosort)', axis: 'y', stop: function (event, ui) { // obtain index of moved item var index = $(this).children(':not(.nosort)').index(ui.item); $('#index').text(index); } }).disableselection(); });
Comments
Post a Comment