JQueryUI 连接列表 +可在选项卡中排序

发布于 2024-10-21 19:08:01 字数 3151 浏览 5 评论 0原文

经过几天在互联网上寻找解决方案(我对 HTML、JQuery、php 真的很陌生,我是一名 as400 rpg 程序员,现在正在转向这种架构),最后我在这里寻求一个解决方案帮助。我想在一个选项卡中获取可排序的项目列表(并且已完成),并且从该列表中我想将一个项目拖动到另一个选项卡,这是主要问题:以下代码正在工作,但我无法拖入第一个选项卡。在可排序中,我放置了警报以可视化选项卡代码并查看更新是否正在运行。在 php 中,我放置了编写数据库的代码,我必须使用列表中的信息来更新该数据库。我从 JQueryUI.com 复制了所有代码。

$(document).ready(function() {

        $( "ul.dropfalse" ).sortable({
        connectWith: "ul.dropfalse",
        cursor: 'crosshair',
                    opacity: 0.8,
        placeholder: "ui-state-highlight",
        revert: true,
        scroll: true,
        update: function (event, ui) {
                            var target = event.target.id;
                alert(target);
                var order = $(this).sortable('serialize');
                $("#update").load("tabsitem.php?"+order);
                alert("update")
                }
    });

    $( "#sortable" ).disableSelection();

    $( "#tabs" ).tabs();

})  

<div id="tabs">
    <ul>
       <li><a href="#tabs-1">Tab 1</a></li>
       <li><a href="#tabs-2">Tab 2</a></li>
       <li><a href="#tabs-3">Tab 3</a></li>
    </ul>
<div id="tabs-1">
    <ul id="sortable1" class='dropfalse'>
        <li id="TABItem_11"><img src="arrow.png" alt="move" />1st TAB.Item 1</li>
        <li id="TABItem_12"><img src="arrow.png" alt="move" />1st TAB.Item 2</li>
        <li id="TABItem_13"><img src="arrow.png" alt="move" />1st TAB.Item 3</li>
        <li id="TABItem_14"><img src="arrow.png" alt="move" />1st TAB.Item 4</li>
        <li id="TABItem_15"><img src="arrow.png" alt="move" />1st TAB.Item 5</li>
    </ul>
</div>
<div id="tabs-2">
    <ul id="sortable2" class='dropfalse'>
        <li id="TABItem_21"><img src="arrow.png" alt="move" />2nd TAB.Item 1</li>
        <li id="TABItem_22"><img src="arrow.png" alt="move" />2nd TAB.Item 2</li>
        <li id="TABItem_23"><img src="arrow.png" alt="move" />2nd TAB.Item 3</li>
        <li id="TABItem_24"><img src="arrow.png" alt="move" />2nd TAB.Item 4</li>
        <li id="TABItem_25"><img src="arrow.png" alt="move" />2nd TAB.Item 5</li>
    </ul>
</div>
<div id="tabs-3">
    <ul id="sortable3" class='dropfalse'>
        <li id="TABItem_31"><img src="arrow.png" alt="move" />3rd TAB.Item 1</li>
        <li id="TABItem_32"><img src="arrow.png" alt="move" />3rd TAB.Item 2</li>
        <li id="TABItem_33"><img src="arrow.png" alt="move" />3rd TAB.Item 3</li>
        <li id="TABItem_34"><img src="arrow.png" alt="move" />3rd TAB.Item 4</li>
        <li id="TABItem_35"><img src="arrow.png" alt="move" />3rd TAB.Item 5</li>
    </ul>
</div>
</div>
<pre>
    <div id="update">Waiting for update</div>
</pre>

还有另一个问题:为什么当我放入另一个选项卡时,该项目总是放在列表中的第四位? 感谢任何人都可以帮助我。

after days passed on the internet searching for a solution (I'm really new with HTML, JQuery, php, I'm an as400 rpg programmer that now is moving to this kind of architecture), finally I'm here to ask for a help. I want to obtain a sortable list of items in one tab (and this is done) and from this list I want to drag one item to another tab and this is the main problem : the following code it's working but I can't drag into the first tab. In the sortable I have put the alert to visualize the tab code and to see that the update is working. In the php I put the code to write the database which I have to update with the information from the lists. I copied all the code from JQueryUI.com.

$(document).ready(function() {

        $( "ul.dropfalse" ).sortable({
        connectWith: "ul.dropfalse",
        cursor: 'crosshair',
                    opacity: 0.8,
        placeholder: "ui-state-highlight",
        revert: true,
        scroll: true,
        update: function (event, ui) {
                            var target = event.target.id;
                alert(target);
                var order = $(this).sortable('serialize');
                $("#update").load("tabsitem.php?"+order);
                alert("update")
                }
    });

    $( "#sortable" ).disableSelection();

    $( "#tabs" ).tabs();

})  

<div id="tabs">
    <ul>
       <li><a href="#tabs-1">Tab 1</a></li>
       <li><a href="#tabs-2">Tab 2</a></li>
       <li><a href="#tabs-3">Tab 3</a></li>
    </ul>
<div id="tabs-1">
    <ul id="sortable1" class='dropfalse'>
        <li id="TABItem_11"><img src="arrow.png" alt="move" />1st TAB.Item 1</li>
        <li id="TABItem_12"><img src="arrow.png" alt="move" />1st TAB.Item 2</li>
        <li id="TABItem_13"><img src="arrow.png" alt="move" />1st TAB.Item 3</li>
        <li id="TABItem_14"><img src="arrow.png" alt="move" />1st TAB.Item 4</li>
        <li id="TABItem_15"><img src="arrow.png" alt="move" />1st TAB.Item 5</li>
    </ul>
</div>
<div id="tabs-2">
    <ul id="sortable2" class='dropfalse'>
        <li id="TABItem_21"><img src="arrow.png" alt="move" />2nd TAB.Item 1</li>
        <li id="TABItem_22"><img src="arrow.png" alt="move" />2nd TAB.Item 2</li>
        <li id="TABItem_23"><img src="arrow.png" alt="move" />2nd TAB.Item 3</li>
        <li id="TABItem_24"><img src="arrow.png" alt="move" />2nd TAB.Item 4</li>
        <li id="TABItem_25"><img src="arrow.png" alt="move" />2nd TAB.Item 5</li>
    </ul>
</div>
<div id="tabs-3">
    <ul id="sortable3" class='dropfalse'>
        <li id="TABItem_31"><img src="arrow.png" alt="move" />3rd TAB.Item 1</li>
        <li id="TABItem_32"><img src="arrow.png" alt="move" />3rd TAB.Item 2</li>
        <li id="TABItem_33"><img src="arrow.png" alt="move" />3rd TAB.Item 3</li>
        <li id="TABItem_34"><img src="arrow.png" alt="move" />3rd TAB.Item 4</li>
        <li id="TABItem_35"><img src="arrow.png" alt="move" />3rd TAB.Item 5</li>
    </ul>
</div>
</div>
<pre>
    <div id="update">Waiting for update</div>
</pre>

There is also another question : why when I drop into another tab, the item is always put to the 4th place in the list ?
Thank to anybody could help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文