Peter
Peter

Reputation: 1

jQuery UI droppable "out" event doesn't trigger

On "over"-ing I'm rebuilding the droppable elements by $(this).parent.empty().append(...) (they basically consist of <li> elements)

The problem is that the actual element, awaiting the "out" function to be triggered is deleted as well --> out cannot be fired

is there any solution for this kind of problem?

Upvotes: 0

Views: 619

Answers (1)

Matt
Matt

Reputation: 7249

Have you tried .live. This will add it back on if you create the elements after the DOM has been loaded already. So if you have some thing like $("#mylist li").live('handler', function(){}); Im not sure exactly what you are doing, but it would be something like this.

You can see some examples here: http://api.jquery.com/live/

And in face you can do multiple handlers.

$("#mylist li").live("mouseover mouseout", function(event) {
  if ( event.type == "mouseover" ) {
    // do something on mouseover
  } else {
    // do something on mouseout
  }
});

Delegate as Husky suggested:

$("#mylist").delegate("li", "mouseover mouseout", function(event) {
  if ( event.type == "mouseover" ) {
    // do something on mouseover
  } else {
    // do something on mouseout
  }
});

Upvotes: 1

Related Questions