6

i am looking for a way to .preventDefault() to make a transition and then allow the default behavior

$('.withTrans').click(function(e){
    e.preventDeault();
    $(this).animate('opacity','0',300,function(){
           e.resumeDefault();      // does something like this exist?
    });

})
Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378

3 Answers3

6
$('.withTrans').click(function(event) {
    if ( $(this).data("prevented") === true ) {
        $(this).data("prevented", false);
        return;
    }
    event.preventDefault();
    $(this).animate('opacity', '0', 300, function() {
           $(this).data("prevented", true).trigger("click");
    });
});
Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
1

assuming you are trying to follow a link after the animation is complete:

$('.withTrans').click(function(e){
    $(this).animate('opacity','0',300,function(){
          window.location= this.href;
    });
    return false;
});
charlietfl
  • 170,828
  • 13
  • 121
  • 150
0
$('.withTrans').each(function(e){
    $(this).unbind();
}
john k
  • 6,268
  • 4
  • 55
  • 59