bootstrap4-toggle icon indicating copy to clipboard operation
bootstrap4-toggle copied to clipboard

Delay does not work

Open xbaha opened this issue 5 years ago • 1 comments

the code inside the delay function never get excused. if no delay, it's executed, not sure if it's a related bug. but i want to delay the toggle so that my database does not execute a save on each click if someone clicked 100s of times!

    $('#toggle-event').change(function() {
    
     setTimeout(  function()   {
       $(this).prop('disabled',false);
  }, 1000);
  
      setTimeout(  function()   {
       $(this).prop('disabled',true);
  }, 10);
})

xbaha avatar Nov 08 '19 16:11 xbaha

I think your code is messing up with this. Here is what I suppose you want:

 $('#toggle-event').change(function() {
    var $elem = $(this);

     setTimeout(  function()   {
           $elem.prop('disabled',false);
      }, 1000);
  
      setTimeout(  function()   {
            $elem.prop('disabled',true);
       }, 10);
})

nikitul avatar Apr 06 '20 21:04 nikitul