javascript - Jquery unbind events -


i have 2 scripts

$(".makebid").on('click', function(e) {         e.preventdefault();         if ($('#pop_up').length) {$('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});}         var strsrc = 'index.asp?id=' + $(this).attr('id');         $.get(strsrc, function(data) {             if ($('#pop_up').length) {                 $('<iframe src="' + strsrc + '"/>').appendto('#pop_up');                 $('#pop_up').show(function() {                     $('#pop_up').height(150).width(800);                     $('#pop_up').offset({top:e.pagey,left:e.pagex});                     $('#pop_up').on( "mouseleave", function() {                         if ($('#pop_up').length) {                             $('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});                             $('#pop_up').hide();                           }                         $('#pop_up').unbind();                     });                     $('.authorize-close').click(function(e){                               e.preventdefault();                         if ($('#pop_up').length) {                             $('#pop_up').html("");                             $('#pop_up').hide();                          }                     });                 });             }         }); $(".makebid").unbind('click'); });  

and

$(".login").on('click', function(e) {         e.preventdefault();         if ($('#pop_up').length) {$('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});} //restore div position , offset         var strsrc = 'index.asp?id=' + $(this).attr('id');         $.get(strsrc, function(data) {             if ($('#pop_up').length) {                 $('<iframe src="' + strsrc + '"/>').appendto('#pop_up');                 $('#pop_up').show(function() {                     $('#pop_up').height(150).width(800); //set div size                     $('#pop_up').offset({top:e.pagey,left:e.pagex}); // set div offset                     $('.authorize-close').click(function(e){     //on close button press                           e.preventdefault();                         if ($('#pop_up').length) {                             $('#pop_up').html(""); //empty div                             $('#pop_up').hide(); // hide div                         }                     });                 });             }         }); $(".login").unbind('click'); });  

so when click .makebid $('#pop_up').on( "mouseleave", activated , after close #pop_up , click on .login $('#pop_up').on( "mouseleave", still working.

how unbind this?

you have modifiy $('#pop_up').unbind(); $('#pop_up').off("mouseleave"); below code

 $('#pop_up').on( "mouseleave", function() {                      if ($('#pop_up').length) {                          $('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});                          $('#pop_up').hide();                         }                      $('#pop_up').off("mouseleave");                  });


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -