javascript - jQuery ui sortable toArray skips 1 item -
i'm trying put li id's itemwrapper in 1 array after order has been changed.
it loses 1 item time. doesn't matter how li's there are. everytime it's missing 1 li id.
what doing wrong?
var result = ""; $("#itemwrapper").sortable({change: function(event, ui) { result = $("#itemwrapper").sortable("toarray"); }}); $(".colitem").disableselection(); <ul id="itemwrapper" style="list-style-type:none;"> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_48_0_1"><img src="../images/items/1309680939.jpg" width="190" height="130" alt="3768" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_50_0_1"><img src="../images/items/1309681037.jpg" width="190" height="130" alt="3765" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_58_0_1"><img src="../images/items/1309681326.jpg" width="190" height="130" alt="3768" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_51_0_1"><img src="../images/items/1309681056.jpg" width="190" height="130" alt="11090" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_52_0_1"><img src="../images/items/1309681077.jpg" width="190" height="130" alt="3766" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_53_0_1"><img src="../images/items/1309681100.jpg" width="190" height="130" alt="3769" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_54_0_1"><img src="../images/items/1309681118.jpg" width="190" height="130" alt="11092" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_55_0_1"><img src="../images/items/1309681135.jpg" width="190" height="130" alt="11077" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_56_0_1"><img src="../images/items/1309681155.jpg" width="190" height="130" alt="3762" /></li> <li class="colitem ui-state-default" style="margin-right:-5px;" id="item_57_0_1"><img src="../images/items/1309681177.jpg" width="190" height="130" alt="3761" /></li> </ul>
i think problem using wrong event. if use "stop" works. fiddle here: http://jsfiddle.net/jeypj/
$("#itemwrapper").sortable({stop: function(event, ui) { result = $("#itemwrapper").sortable("toarray"); console.log(result.length); }}); thi related fact, think, change event triggered while sorting: in case doesn't count item sorting.
Comments
Post a Comment