【问题标题】:Drag and Drop Sortable拖放可排序
【发布时间】:2017-03-28 00:24:08
【问题描述】:

我只是想知道我可以在哪里放置一些功能在我的拖放。我尝试使用警报消息来了解事件发生的位置,但它没有执行我的任何警报框。我在评论中放置了警告框,这些是我曾经放置过的地方,但没有任何反应。我的拖放工作,但它不能触发警报框。我不知道出了什么问题。帮我。谢谢。

var adjustment;
$(function () {
    $("#container1, #container2").sortable({
        group: 'ol.simple_with_animation',
        pullPlaceholder: false,

        onDragStart: function ($item, container, _super) {
            var offset = $item.offset(),
                pointer = container.rootGroup.pointer;

            adjustment = {
                left: pointer.left - offset.left,
                top: pointer.top - offset.top
            };

            _super($item, container);

        },
        onDrag: function ($item, position) {
            $item.css({
                left: position.left - adjustment.left,
                top: position.top - adjustment.top
            });
          //  alert('oink');
        },

        onDrop: function ($item, container, _super) {
            var $clonedItem = $('<li/>').css({ height: 0 });
            $item.before($clonedItem);
            $clonedItem.animate({ 'height': $item.height() });
          //  alert('wew');
            $item.animate($clonedItem.position(), function () {
                $clonedItem.detach();
                _super($item, container);
           //     alert('oink');
            });
         //   alert('oink');
        },

    });
    //alert('oink');
});

【问题讨论】:

  • 大声笑“oink”大声笑。

标签: drag-and-drop jquery-ui-sortable


【解决方案1】:

这对我来说很完美。希望它也能帮助那些挣扎的人:)

    $("#container1, #container2").sortable(
        {
            group: 'ol.simple_with_animation',
            onDrop: function ($item, container, _super) {

                            var $clonedItem = $('<li/>').css({ height: 0 });
                            $item.before($clonedItem);
                            $clonedItem.animate({ 'height': $item.height() });

                            $item.animate($clonedItem.position(), function () {
                                $clonedItem.detach();
                                _super($item, container);

                            });
                            alert('oink');
                        }
        });

【讨论】:

    猜你喜欢
    • 2013-12-14
    • 2019-05-23
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 2013-03-19
    • 1970-01-01
    • 2010-09-10
    • 2014-08-31
    相关资源
    最近更新 更多