如何运行接收方法可排序

发布于 2024-11-26 01:36:40 字数 930 浏览 0 评论 0原文

在此标准示例中 http://jqueryui.com/demos/sortable/#connect-lists-through -tabs

<script>
$(function() {
    $( "#sortable1, #sortable2" ).sortable().disableSelection();

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

    var $tab_items = $( "ul:first li", $tabs ).droppable({
        accept: ".connectedSortable li",
        hoverClass: "ui-state-hover",
        drop: function( event, ui ) {
            var $item = $( this );
            var $list = $( $item.find( "a" ).attr( "href" ) )
                .find( ".connectedSortable" );

            ui.draggable.hide( "slow", function() {
                $tabs.tabs( "select", $tab_items.index( $item ) );
                $( this ).appendTo( $list ).show( "slow" );
            });
        }
    });
});
</script>

当您添加到拳头列表时如何运行接收方法,以便我添加到数据库并在您返回时删除

In this standard example
http://jqueryui.com/demos/sortable/#connect-lists-through-tabs

<script>
$(function() {
    $( "#sortable1, #sortable2" ).sortable().disableSelection();

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

    var $tab_items = $( "ul:first li", $tabs ).droppable({
        accept: ".connectedSortable li",
        hoverClass: "ui-state-hover",
        drop: function( event, ui ) {
            var $item = $( this );
            var $list = $( $item.find( "a" ).attr( "href" ) )
                .find( ".connectedSortable" );

            ui.draggable.hide( "slow", function() {
                $tabs.tabs( "select", $tab_items.index( $item ) );
                $( this ).appendTo( $list ).show( "slow" );
            });
        }
    });
});
</script>

When you adding to fist list how run receive method so I add to database and remove when you moving back

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆之渊 2024-12-03 01:36:40

这取决于您的后端编码。例如,如果您使用 php,您可能想使用 jQuery 进行 AJAX 调用:

jQuery(document).ready(function ($) {
 $( "#sortable1, #sortable2" ).sortable().disableSelection();

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

var $tab_items = $( "ul:first li", $tabs ).droppable({
    accept: ".connectedSortable li",
    hoverClass: "ui-state-hover",
    drop: function( event, ui ) {
        var $item = $( this );
        var $list = $( $item.find( "a" ).attr( "href" ) )
            .find( ".connectedSortable" );

    /* Then over here, you can make your AJAX post to your .php file */
       $.ajax({
         type: "POST",
         url: "saveorder.php",
         data: "list=" + list
       });

        ui.draggable.hide( "slow", function() {
            $tabs.tabs( "select", $tab_items.index( $item ) );
            $( this ).appendTo( $list ).show( "slow" );
        });
    }
 });
});

然后,如果您的 PHP 文件,您可以放置​​类似这样的内容:

<?php if (isset($_POST['list'])) {
    $list_order = $_POST['list']; // Clean the data first though.
    mysql_query("INSERT INTO list_order (order) VALUES ('$list_order')");
} ?>

类似的内容。希望它有帮助:)

This depends on what your backend is coded in. For instance, if you are using php, you may want to use jQuery to make an AJAX call:

jQuery(document).ready(function ($) {
 $( "#sortable1, #sortable2" ).sortable().disableSelection();

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

var $tab_items = $( "ul:first li", $tabs ).droppable({
    accept: ".connectedSortable li",
    hoverClass: "ui-state-hover",
    drop: function( event, ui ) {
        var $item = $( this );
        var $list = $( $item.find( "a" ).attr( "href" ) )
            .find( ".connectedSortable" );

    /* Then over here, you can make your AJAX post to your .php file */
       $.ajax({
         type: "POST",
         url: "saveorder.php",
         data: "list=" + list
       });

        ui.draggable.hide( "slow", function() {
            $tabs.tabs( "select", $tab_items.index( $item ) );
            $( this ).appendTo( $list ).show( "slow" );
        });
    }
 });
});

Then, if your PHP file, you put something like this:

<?php if (isset($_POST['list'])) {
    $list_order = $_POST['list']; // Clean the data first though.
    mysql_query("INSERT INTO list_order (order) VALUES ('$list_order')");
} ?>

Something like that. Hope it helps :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文