NestedSortable,toHierarchy返回undefined

时间:2016-05-26 09:49:19

标签: jquery html serialization undefined nested-sortable

我尝试为行构建nestedsortable标头(下面是HTML代码)。每件事都很完美。标题是动态建立通过PHP,我可以排序。但是通过toHierarchy序列化返回给我未定义的对象( [undefined,undefined,undefined])。有什么想法吗?

<ol class="sortable ui-sortable mjs-nestedSortable-branch mjs-nestedSortable-expanded">
<li style="display: list-item;" class="mjs-nestedSortable-branch mjs-nestedSortable-expanded" data-dbrowid="700">
    <div class="rowTitle projectbg ui-sortable-handle" data-dbrowid="700" data-parentrowid="700" data-recordtype="10" data-refrecid="309" data-projid="309">Fonteyn</div>
    <ol>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="739">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="739" data-parentrowid="700" data-recordtype="60" data-refrecid="23" data-projid="309">BIG Szczecin (2) T+S</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="824">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="824" data-parentrowid="700" data-recordtype="60" data-refrecid="2" data-projid="309">GROM (4) J+G+P+R</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="782">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="782" data-parentrowid="700" data-recordtype="80" data-refrecid="1" data-projid="309">Bartek + Krzysztof - engineering</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="834">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="834" data-parentrowid="700" data-recordtype="60" data-refrecid="23" data-projid="309">BIG Szczecin (2) T+S</div>
        </li>
    </ol>
</li>
<li style="display: list-item;" class="mjs-nestedSortable-branch mjs-nestedSortable-expanded" data-dbrowid="203">
    <div class="rowTitle vrij ui-sortable-handle" data-parentrowid="203" data-recordtype="20" data-refrecid="299" data-projid="299">VRIJ – WOLNE</div>
    <ol>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="413">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="413" data-parentrowid="203" data-recordtype="60" data-refrecid="27" data-projid="299">Robert (4) R+M+A+J</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="769">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="769" data-parentrowid="203" data-recordtype="70" data-refrecid="22" data-projid="299">Waldek</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="448">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="448" data-parentrowid="203" data-recordtype="60" data-refrecid="20" data-projid="299">BIG Police (2) A+D</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="831">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="831" data-parentrowid="203" data-recordtype="70" data-refrecid="12" data-projid="299">André</div>
        </li>
    </ol>
</li>
<li style="display: list-item;" class="mjs-nestedSortable-branch mjs-nestedSortable-expanded" data-dbrowid="204">
    <div class="rowTitle wensen ui-sortable-handle" data-parentrowid="204" data-recordtype="30" data-refrecid="300" data-projid="300">WENSEN – ŻYCZENIA</div>
    <ol>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="466">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="466" data-parentrowid="204" data-recordtype="70" data-refrecid="17" data-projid="300">Moni(cz)ka</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="518">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="518" data-parentrowid="204" data-recordtype="70" data-refrecid="35" data-projid="300">Gosia</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="615">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="615" data-parentrowid="204" data-recordtype="70" data-refrecid="42" data-projid="300">Janek G.</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="617">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="617" data-parentrowid="204" data-recordtype="70" data-refrecid="8" data-projid="300">Jan</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="742">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="742" data-parentrowid="204" data-recordtype="70" data-refrecid="15" data-projid="300">Laura</div>
        </li>
        <li style="display: list-item;" class="mjs-nestedSortable-leaf" data-dbrowid="838">
            <div class="rowTitle ui-sortable-handle" data-dbrowid="838" data-parentrowid="204" data-recordtype="70" data-refrecid="41" data-projid="300">Kamil</div>
        </li>
    </ol>
</li>

 $('ol.sortable').nestedSortable({
             forcePlaceholderSize: true,
             handle: 'div',
             helper:    'clone',
             items: 'li',
             opacity: .6,
             placeholder: 'placeholder',
             revert: 250,
             tabSize: 25,
             tolerance: 'pointer',
             toleranceElement: '> div',
             maxLevels: 2,
             isTree: true,
             expandOnHover: 700,
             startCollapsed: false,
             disableParentChange: true,
             relocate: function(){
                     var array = $(this).nestedSortable('toHierarchy', {startDepthCount: 0});

                    console.log(sortArray);
            }
        });

1 个答案:

答案 0 :(得分:3)

哈哈哈:) 现在完美无缺:D 很简单:) NestedSortable需要将id添加到 li 对象。我必须从menuItem _ ###开始。 ###必须是一个数字。