Skip to content Skip to sidebar Skip to footer

Add To Jquery-ui Sortable List

Simple question about Jquery-UI sortable lists I have made:
).val(); var $li = $("<li class='ui-state-default'/>").text(text); $("#sortable").append($li); $("#sortable").sortable('refresh'); });

You can try it here.

Solution 2:

For me, the $("#sortable").sortable('refresh'); didn't worked.

But this worked: $("#sortable").trigger("sortupdate");

Solution 3:

I know it's not exactly the answer but @karim79 helped me to find a way to add an image to the sortable list, if anyone needs it here it is:

<inputtype='file' onchange="readURL(this);" style="width: 100%;" />

functionreadURL(input) {
    if (input.files && input.files[0]) {
        var reader = newFileReader();
        reader.onload = function (e) {
            var $li = $("<li class='ui-state-default'/>");
            $li.append('<img src="'+ e.target.result +'" width="150" height="200" />');
            $("#sortable").append($li);
            $("#sortable").sortable('refresh');
        };
        reader.readAsDataURL(input.files[0]);
    }
}

Solution 4:

$("selector").sortable('refresh') 

works fine.

There is one more thing to be aware of:

handle:'.iORAS_ORD'

If you use handle with sortable, don't use jquery for selection, like:

handle: $('.iORAS_ORD')

If using jQuery, sorting after insert is not possible on newly inserted items. More on the subject here.

Post a Comment for "Add To Jquery-ui Sortable List"