drgullin / icheck

Highly customizable checkboxes and radio buttons (jQuery & Zepto)
http://fronteed.com/iCheck
7.39k stars 1.63k forks source link

How to use event.stopPropagation(); #375

Open SirwanAfifi opened 7 years ago

SirwanAfifi commented 7 years ago

Before a check box is checked I have some validations, so if there are errors I don't want the check box be selected, for regular input we can use event.stopPropagation(); which actually stops the event bubbling up through the DOM. But this behavior doesn't work with iCheck:

$('#invitingAllMembers').on('ifChecked', function (event) {
    if (errors) {
        event.stopPropagation();
    }
});

$('#invitingAllMembers').on('ifUnchecked', function (event) {
    // ....
});

You suggest something like this:

$(this).iCheck('uncheck');

But the problem is that, it triggers the ifUnchecked event.

Any idea?

jasminetracey commented 6 years ago

Hey did you find a solution?

lquijije commented 5 years ago

$('input').prop('checked', false).icheck('updated');

IshanFx commented 5 years ago

Any solution for this?

DavePlater commented 3 years ago

(Note v1.0.2) The ONLY way I have found to stop my checkbox from changing state is to use "throw" which seems naughty. No amount of stopPropagation() or preventDefault() or return false or iCheck('uncheck') would stop the check state from changing.

gesitaric commented 3 years ago

same issue here! Any solutions??