I found another way of doing it that is rather sneaky. Maybe someone
else will find it useful. I pull out liveHandler and make my own
live.add function.
var liveHandler = null;
(function(){
var add = jQuery.event.add;
jQuery.event.add = function(el, event, handler, data){
if(data.selector == "stealing" && !event)
liveHandler = handler;
else
add.apply(this, arguments)
}
var f = function(){}, d = {selector: "stealing"}
jQuery.event.add(document, "live",f,d);
jQuery.event.remove(document, "live",f,d);
jQuery.event.add = add;
})();
//hack live to provide what we need
jQuery.event.special.live.add = function( proxy, data, namespaces,
live ) {
jQuery.extend( proxy, data || {} );
proxy.guid += data.selector + data.live;
data.liveProxy = proxy;
jQuery.event.add( this, data.live, liveHandler,
data );
}
On Jan 13, 11:40 pm, Justin Meyer <[email protected]> wrote:
> I'm trying to implement drag-drop for live events:
>
> $(".handle").live("dropped", func1);
> $(".drop").live("dropon", func2);
>
> I'm unable to get it working without needing to change jQuery, but not
> significantly. Are these types of patches still going to be accepted?
>
> The problem is that an efficient drag plugin works differently than
> submit / change. It's not just filtering other events. Instead it's
> setting up a variety of events on elements other then the element
> being delegated on, and modifying the element.
>
> Here's my method:
>
> 1. when event.special[dragstart|dragend|dragging].setup is called,
> save a reference to your callback on the delegated element's data
>
> 2. if you are the first event listening for a given selector,
> delegate on mousedown for that selector
>
> 3. When mousedown is called, listen on the document for mousemove and
> mouseup
>
> 4. On mousemove, call dragging handlers for the current selector,
> update the position of the draggable.
>
> 5. On mouseup, call dragend handlers for the current selector.
>
> The problem is that I can't get the original event handler passed into
> live (the proxy). Can special.live.add add the proxy into the
> liveHandler data?
>
> data.liveProxy = proxy;
>
> This is a very minor change, but will allow for a lot of special live
> events. Thanks.
--
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en.