suppose I have a nomal function:
function begin(e) {
e.dataTransfer.effectAllowed = 'copy';
e.dataTransfer.setData('text', this.id);
}
I want the same function could appear in one element's live function:
$('img.clone').live('click', function (e) {
e.dataTransfer.effectAllowed = 'copy';
e.dataTransfer.setData('text', this.id);
})
situation1:the firebug would say the e.dataTransfer is undefined? however,if I change to this :
$('img.clone').live('click', function () {
begin(e);
})
this could not doesn't work ,it also says e.dataTransfer is undefined,
but if I use it in addEventListener('dragstart', begin, false),this could work?
So how can I pass the "e" correctly in live() method?
e.dataTransfer
is undefined not e
.
Try
e.originalEvent.dataTransfer
...
jQuery stores the original event in e.originalEvent
, the e
itself is not a real event object but a normal object that jQuery created.