开发者

How to prevent jQuery Droppable from accepting certain Draggable?

I'm creating a page with "groups" of droppable w开发者_Python百科idgets, and each draggable can only be dropped on one group of droppables.

I was able to achieve this by the following code:

$("div.droppable").droppable({
    //accept: ".draggable",
    accept: function (draggable) {
        if ($(this).attr("question_id") != null) {
            if ($(this).attr("question_id") == draggable.attr("question_id")) return true;
        }
        return false;
    });

However, now I'm having a little trouble. After dropping, I was not able to move the draggable around droppables in the same group as I could before. I could drop it on a droppable once, move it to another, but I couldn't move it back to the first droppable.

Does anyone know what could have happened? Any input would be appreciated.


No idea what failed in your code. I created this test case on jsFiddle that is working as expected. As seen in this test case, I am using .data to retrieve the question ID.

I hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜