I've got a problem benefiting from script to operate inside a wordpress widget when it's needed. Ideally I must have the ability to hook in to the javascript event fired whenever a widget is dropped right into a sidebar, or once the widget is opened up up the very first time to operate some setup javascript.

Regrettably script tags included in the widget form itself are removed out unless of course the widget has already been inside a sidebar, therefore the problem is available whenever a new widget is added dynamically and has not been saved yet.

I have got an awful hacky solution utilizing a jquery .live() event binding on mouseover from the widget to fireplace off my code but Let me think there's an easy method.

Simply to clarify, by WordPress 3.2.1, the precise selector you would employ could be "div.icons-sortables", therefore the code would seem like:

jQuery('div.widgets-sortables').bind('sortstop',function(event,ui){
    // run js after widget dropped into sidebar area
});

I acquired the tumbleweed badge for that one!

Anyway, the reply is:

$( ".selector" ).bind( "sortstop", function(event, ui) {
  ... 
});