Is it possible to cancel action of iCheck on ifToggled? I have unchecked input:
$('input').iCheck().on('ifToggled', function(e) {
if (confirm('Don\'t check?')) {
return false;
}
});
Input still gets checked (JSFiddle simple example). Is there any way to cancel event?
So I had to stick with not so nice workaround using a timeout
$('input').iCheck({
checkboxClass: 'icheckbox_flat'
}).on('ifToggled', function(e) {
if ($('input').is(':checked') && confirm('Don\'t check?')) {
setTimeout(function() {
$('input').iCheck('uncheck');
}, 50);
}
});
JSFiddle
If anyone has a better solution, would love to hear it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With