jquery sortable cannot be dragged outside of accordion

早过忘川 提交于 2019-12-02 02:48:58
Edyn

In your sortable call you want to use the following options:

helper: "clone", appendTo: "body", // or whatever element you want the helper clone to be attached to

This does two things. First it makes a copy of the element being dragged (helper option), second it attaches that helper to the specified element (appendTo option).

Similar question here: jQuery-Ui: Cannot drag object outside of an accordion

I'm a little late, I know, but I had a similar problem with two sortable accordions where you can drag&drop items between the two accordions.

So, for future reference:

I also couldn't get the accordion-items to "go out" of the source-accordion, and google led me to this question.

I solved my problem by adding axis: undefined on the sortable() function:

        $("#accordion1")
        .accordion({
            collapsible: true,
            header: "> div > h3",
            dropOnEmpty: true,
            autoHeight: false,
            active: false
        })
        .sortable({
            axis: "y",
            handle: "h3",
            stop: function() {
                stop1 = true;
            },
            connectWith: '.connectedSortable',
            helper: 'clone',
            axis: undefined
        });

Now the accordion-items can be dragged all over the place.

paste a sample of your code so we know what you have left out... it seems that while you are on mouse down... then your accordion fires an event... i could be wrong but sounds like it... so try and have a look at propagation and stopPropagation on jquery.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!