Reputation: 75
I need to overwrite the events but, the application has an option to return the original events to each element of the document. Any ideas?
For example:
<div class="mydiv">
</div>
$(document).delegate( '.mydiv', click', function () {
alert('This is the original event my event!');
});
$(document).delegate( '.mydiv', 'click', function() {
alert('Do this and ignore de previous...');
// For example: How to return the original event when mouseleave event will executed?
});
$(document).delegate( '.mydiv', 'mouseleave', function() {
// return the original event of mydiv
});
Upvotes: 0
Views: 47
Reputation: 154
try to check click event in functions
$(document).delegate( '.mydiv', click', function () {
if(clicked){
return;
}
alert('This is the original event my event!');
});
$(document).delegate( '.mydiv', 'click', function() {
if(!clicked){
return;
}
alert('Do this and ignore de previous...');
});
Upvotes: 0
Reputation: 40639
Use undelegate function
before creating new click
function
Docs http://api.jquery.com/undelegate/
Upvotes: 1