开发者

jQuery UI Sortable does not serialize/toArray child elements

I have the following list and when I call toArray or serialize it only offers me the parent <li>. I am trying to get hold of the whole hierarchy so I can store this information into a self referencing heirachy table in the database. The result here shows item_1,q_6,a_7,g_8. Where is item_3,item_4,item_5.

Thanks

<div id="example5">
    &l开发者_JS百科t;ul>
         <li id="item_1">Item 1
            <ul id="item_2">
                <li id="item_3">Item 1 1<ul></ul></li>
                <li id="item_4">Item 1 2<ul></ul></li>
                <li id="item_5">Item 1 3<ul></ul></li>
             </ul>
         </li>
         <li  id="q_6">Item 2<ul></ul></li>
         <li  id="a_7">Item 3<ul></ul></li>
         <li  id="g_8">Item 4<ul></ul></li>
    </ul>
</div>

<button id="fred">Click</button>

$("#fred").click(function () {
   //var result = $('#example5 ul').sortable('toArray');
   var result = $('#example5 ul').sortable('serialize'); //Neither work

   alert(result);
});


As far as I can tell there's no default way of serializing nested sortable lists in jquery UI.

The best way to do it is to go through every child of "#example5 ul" and build your own structure (I would recommend JSON in this case) to be send to the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜