Solve the problem of multiple function execution when the HTML button is clicked after switching and binding different functions

  • 2020-03-30 02:57:27
  • OfStack

Delete post and lock post need to fill in the reason of rejection, share a window, and button, button binding different events:

Title = 'delete post (blocked, not displayed)';
 
$('#btn_ok', '#div_deny_reason').bind('click', function(){edit('if_show', '0');}); 
title = ' Lock the post '; 
$('#btn_ok', '#div_deny_reason').bind('click', function(){edit('if_lock', '1');}); 

As a result, once the post is locked, and then deleted, edit() is executed twice.

Just change it to the following:
 
title = ' Delete posts ( Blocked, not displayed )'; 
$('#btn_ok', '#div_deny_reason').one('click', function(){edit('if_show', '0');}); 
title = ' Lock the post '; 
$('#btn_ok', '#div_deny_reason').one('click', function(){edit('if_lock', '1');}); 

Related articles: