I was trying to figure out how I can pass my custom array to JQuery UI sortable widget so I can have the HTML elements created by some logic and not hardcode it but I cannot seem to find anything. For getting the data back I found a toArray method but that seems to be getting an empty array. Below is my code.
<div class="demo">
<ul id="sortable">
</ul>
</div>
$("#sortable").sortable({
});
$("#sortable").disableSelection();
var data = [];
function GetData()
{
for (i = 0; i < 10; i++)
{
data.push(new CustomObject(i,i));
}
}
var CustomObject = function(name,id)
{
this.name = name;
this.id = id;
}
What I want to do is create the sortable data using data array so id becomes the id and name become the display part. And then on some save button I want to retrieve the sorted array. Can someone please tell me how to achieve this.
Here is the Fiddle Link
Thanks