Here is my issue:
i want to prevent the checkbox checked event base on some condition, when user check the checkbox, i call the ifchecked callback, and validate some condition, if the condition is true, prevent the check. However, on matter i return false or event.preventDefault(), the checkbox always checked.
i got a work around, but i am not sure whether it is a proper way:
function asyncEvent(event){
var dfd = jQuery.Deferred();
setTimeout(function () {
dfd.resolve(event);
}, 500);
return dfd.promise();
}
function removeCheck(event){
console.log(event.target);
jQuery(event.target).iCheck('uncheck');
}
jQuery('.input').on("ifChecked",function(event){
//if(condition){
//remove
jQuery.when(asyncEvent(event)).then(removeCheck)}
//}
);
Here is my issue: i want to prevent the checkbox checked event base on some condition, when user check the checkbox, i call the ifchecked callback, and validate some condition, if the condition is true, prevent the check. However, on matter i return false or event.preventDefault(), the checkbox always checked.
i got a work around, but i am not sure whether it is a proper way: