bootstrap4-toggle
bootstrap4-toggle copied to clipboard
Delay does not work
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);
})
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);
})