Search code examples
javascriptjqueryjquery-callbackicheck

iCheck on() method callback not working


I'm using a bootstrap template which use iCheck v1.0.2

When I create an input like this :

<input id="follow_us" type="checkbox">

It generate the result :

<div class="icheckbox_minimal-grey" style="position: relative;">
  <input id="follow_us" type="checkbox" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);">
  <ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins>
</div>

I want to detect the change on this checkbox. As the documentation says, there is a method for that :

$('#follow_us').on('ifChanged', function(event){
  alert(event.type + ' callback');
});

But this did absolutely nothing. Same for every other callbacks. Am I missing something ?


Solution

  • It looks like you didn't initialize the checkbox as an iCheck object. To do so, you will need to add something along the lines of:

    $('#follow_us').iCheck();
    

    to your script before the iCheck callback will work. Check the documentation (linked above) for more info on options you can set at initialization.