drgullin / icheck

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

Checked and un-checked jQuery function with inputs #147

Closed h-sobhy closed 10 years ago

h-sobhy commented 10 years ago

I'm using jQuery function which should be applied on inputs that use iCheck and other inputs that don't use it.

in plugin documentation I have found that I should use:

    $('input').on('ifChecked', function () {
       //function
    });
    $('input').on('ifUnchecked', function () {
       // function
    });

While I'm originally use:

$('input').change(function(){
        if ($(this).is(":checked")) {
           // function
        } else {
            // function
        }
});

How can I find a single way to apply my functions on both types of inputs where some use and other don't use the iCheck plugin?

drgullin commented 10 years ago

You should use a 2.x version, since it supports change event.

Instead of using ifChecked and ifUnchecked, use a change event. You can bind this event for all inputs, both customized and not customized. See a demo http://jsfiddle.net/b78FD/

h-sobhy commented 10 years ago

Thanks @fronteed I was using v0.9.1 got 1.02 and your example as well, thanks