jquery.event.drop-2.0 with jquery 1.7+ ?

205 views
Skip to first unread message

Steve

unread,
Feb 26, 2012, 5:08:46 AM2/26/12
to threed...@googlegroups.com
Hey,

I'm currently using this great library with jquery 1.7.1.
Everything seems to be working fine except for when you try using the plugin with "on".
My problem is that my application has dynamically added content which has to be draggable.

In my case this code doesn't work. If I change "live" to "on" it works, but it attaches only to the current elements and the newly added ones are not draggable.

Is there a patch that can fix this problem?

Steve

xdamman

unread,
Mar 6, 2012, 2:14:57 PM3/6/12
to threedubmedia
Also running into this issue.
I found this https://groups.google.com/forum/#!topic/threedubmedia/94yO2u0TxMc/discussion
but it doesn't solve all my problems. Maybe it can help.

Is the original author of the jquery.event.drag library still alive
and maintaining this library?


On Feb 26, 2:08 am, Steve <ad...@itnews-bg.com> wrote:
> Hey,
>
> I'm currently using this great library with jquery 1.7.1.
> Everything seems to be working fine except for when you try using the
> plugin with "on".
> My problem is that my application has dynamically added content which has
> to be draggable.
>
> In my case this <http://threedubmedia.com/code/event/drop/demo/live> code

Сергей Колоней

unread,
Mar 14, 2012, 12:50:11 PM3/14/12
to threedubmedia
Seems like there was several changes in jquery 1.7 related to inner
representation of live events, so plugin's code which dealt with them
appeared to be incorrect.

I've fixed this issue by rewriting half of code inside plugin's
delegate() function:

// identify potential delegate elements
delegate: function( event ){
// local refs
var elems = [], target,
// element event structure
events = $.data( this, "events" ) || {},
key, i, liver;

// query live events

for (key in events) {

if (key.indexOf("drag") !== 0)
continue;

liver = events[key];
for (i=0; i<liver.length; i++) {
target = $( event.target ).closest( liver[i].selector,
event.currentTarget )[0];

if ( !target )
continue;

$event.add( target, liver[i].origType+'.'+drag.livekey,
liver[i].origHandler || liver[i].handler, liver[i].data );
// remember new elements
if ( $.inArray( target, elems ) < 0 )
elems.push( target );
}
}

// if there are no elements, break
if ( !elems.length )
return false;
// return the matched results, and clenup when complete
return $( elems ).bind("dragend."+ drag.livekey, function(){
$event.remove( this, "."+ drag.livekey ); // cleanup delegation
});
},

I hope it helps :)
It's a pity, but it seems that this plugin isn't maintained.
Message has been deleted

Steve

unread,
May 16, 2012, 12:12:15 PM5/16/12
to threed...@googlegroups.com
I can confirm this seems to fix the problem!

Благодаря Сергей, поздрави от България!
Reply all
Reply to author
Forward
0 new messages