using jQueryUI sortable list with forms

前端 未结 2 2220
萌比男神i
萌比男神i 2021-02-19 04:10

I\'m using jQueryUI to create a sortable list, and the UI part works great in that I can sort the items as desired on the web page. I can\'t figure out, though, how the order o

2条回答
  •  野的像风
    2021-02-19 04:55

    You can use the method .serialize on your sortable object : http://docs.jquery.com/UI/Sortable#method-serialize

    $( "#sortable" ).sortable('serialize') will give you an ajax submittable array of items. Just assign it to an input box if you are not using ajax. Or simply pass it into your data array if using ajax

    EDIT Example here : http://jsfiddle.net/jomanlk/KeAer/2/

    As the jquery docs note, for this to work your elements need to have ids in the form of set_number (e.g. rank_1, rank_2). So I've modified your HTML

    Just remove the return false in the form and the serialized value will be set to the input box on form submission

提交回复
热议问题