Skip to content

Instantly share code, notes, and snippets.

@optikalefx
Created September 7, 2012 16:51
Show Gist options
  • Save optikalefx/3667718 to your computer and use it in GitHub Desktop.
Save optikalefx/3667718 to your computer and use it in GitHub Desktop.
// awesome special event
// this adds the method every time you drop, shouldn't there be a way to just
// add this once to core $.event.drop ?
$.event.special.drop = {
add: function( handleObj ) {
var old_handler = handleObj.handler;
handleObj.handler = function( event ) {
console.log("every time?");
// Modify event object here!
event.getDropData = function() {
var transfer = event.originalEvent.dataTransfer;
return JSON.parse(transfer.getData('application/javascript'));
}
// Call the originally-bound event handler and return its result.
return old_handler.apply( this, arguments );
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment