jquery - Javascript solution ignore clicks proceeding the first click? -


i have button or anchor element redirect user different view. once button clicked, fires db write event. however, when user clicks button multiple times waiting page reload, multiple records created , causes issues application saving form follows.

what best way, maybe in javascript or jquery ignore clicks after first one?

update:

i did , worked -- doesn't disable button returns false on on click event.

<script>   $("#linkresponse").click(function() {     $(this).click(function() {       return false;     });       return true;   }); </script> 

does seem solution, reason shouldn't follow it?

whenever event should occur once element, use jquery's one() method:

$('#mybutton').one('click', function(){   ... }); 

Comments