-1

I want the jquery line that make my div draggable but not accept to be droppable

I have elements that is draggable and droppable but I don't want this div to act the same I just want it to be draggable but not droppable with anything

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • What do you mean draggable and droppable? Can you give an example, maybe a jsfiddle? I have a feeling you are referring the the jQuery UI `.draggable()` function, but I'm not sure. – John Fish Aug 08 '14 at 00:33

1 Answers1

0

Assuming you mean the .draggable() and .droppable() jQuery UI functions, you can use the accept parameter to only accept certain elements to be droppable. This is shown on the jQuery UI reference page for droppable:

$(function () {
    $("#draggable, #draggable-nonvalid").draggable();
    $("#droppable").droppable({
        accept: "#draggable",
        activeClass: "ui-state-hover",
        hoverClass: "ui-state-active",
        drop: function (event, ui) {
            $(this)
                .addClass("ui-state-highlight")
                .find("p")
                .html("Dropped!");
        }
    });
});

The above code will make #draggable and #draggable-nonvalid elements draggable, #droppable droppable, and will make only #draggable be accepted by #droppable.

Link/Source - jQuery UI

John Fish
  • 1,060
  • 1
  • 7
  • 13