javascript - JQuery UI .sortable('toArray') returning HTMLUListElement instead of array of id's -


i'm trying create sorted array out of sortable elements 'toarray' method not work. here's sortable html code:

<div class="control-group" style="cursor:pointer;">     <label class="control-label" for="input-sort">preferences</label>             <div class="controls">             <ul id= "sortable">                     <li class="ui-state-default" id="item1"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 1</li>                     <li class="ui-state-default" id="item2"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 2</li>                     <li class="ui-state-default" id="item3"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 3</li>                     <li class="ui-state-default" id="item4"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 4</li>                     <li class="ui-state-default" id="item5"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 5</li>                     <li class="ui-state-default" id="item6"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 6</li>                     <li class="ui-state-default" id="item7"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 7</li>             </ul>             </div>     </div> 

and here's corresponding javascript:

<script>     var result=$("#sortable").sortable("toarray");     $("#sortable").sortable({         stop: function(event, ui) {             document.getelementbyid("info").innerhtml=result + " , " + result[0];         }     }); </script> 

when display result returns[object object] , [object htmllielement] , tried assigning result $("sortable li") didn't return of elements. appreciated. thanks.

your code doesn't make logical sense, think going after.

$("#sortable").sortable({     stop: function(event, ui) {         $("#info").html(json.stringify($("#sortable").sortable('toarray')));     } }); 

note not work in ie<8 unless include json library.

in code, result never updated therefore contain jquery object, object , not array of values.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -