zuc0001
zuc0001

Reputation: 931

jQuery UI droppable not over

Code:

    $("div.layout.lo-content > div.content").droppable(
    {
        over:function(e,ui)
        {
            alert("yes");
            $(this).css("background-color","#FFFFFF");
        },
        drop: function(e, ui)
        {
            $(ui.draggable).appendTo($(this));
            if($(this).hasClass("ui-sortable"))
            {
                $("div.content").sortable('refresh');
            }
        }
    });

As you can see, when an element is dragged on top of the above element, its background colour will change.

Is there a way to make the background colour transparent if the element is not over the droppable container?

Such as:

{
    notover: function(e,ui) { }
}

Upvotes: 1

Views: 97

Answers (1)

guest271314
guest271314

Reputation: 1

Try

css

div.layout.lo-content > div.content {
  background-color:transparent;
}

js

  $("div.layout.lo-content > div.content").droppable(
    {
        over:function(e,ui)
        {
            alert("yes");
            $(this).css("background-color","#FFFFFF");
        },
        drop: function(e, ui)
        {
            $(ui.draggable).appendTo($(this));
            if($(this).hasClass("ui-sortable"))
            {
                $("div.content").sortable('refresh');
            }
        },
        out:function() {
            $(this).css("background-color","transparent");   
        }

    });

Upvotes: 2

Related Questions