drgullin / icheck

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

2.0rc1: line 341 undefined #128

Closed anotherZero closed 10 years ago

anotherZero commented 10 years ago

I tried icheck 2.0rc1 again and I'm getting an error that crashes the icheck() function. The debug console says that line 341 is the problem.

I did my best to try to see what's wrong on this line, here's what I've found so far:

if I don't declare a window.icheck = {} object, then $.expando seems to be undefined $.cache is always undefined.

Here's my icheck setup

<!-- markup -->
<input type="checkbox" data-checkedClass="icheckbox_flat-blue" class="icheck" id="rememberMe" name="rememberMe"  />
<label for="rememberMe" class="inline"> Remember me </label>
<!-- scripts -->
<script type="application/javascript" src="/js/modernizr.js"></script>
<script type="application/javascript" src="/js/jquery.js"></script>
<script type="application/javascript" src="/js/iCheck/icheck.2.0rc1.js"></script>
<script>
    window.icheck = {
        tap: true
    };
    $('.icheck').icheck({
        checkboxClass: 'icheckbox_flat-blue',
        checkedClass: 'checked'
    });
</script>
drgullin commented 10 years ago

Which version of jQuery do you use?

anotherZero commented 10 years ago

I'm using v2.1.0 currently.

drgullin commented 10 years ago

Current issue is fixed by a latest commit. Thanks @anotherZero.

Note that you don't have to set these lines:

window.icheck = {
  tap: true
};
$('.icheck').icheck({
  checkboxClass: 'icheckbox_flat-blue',
  checkedClass: 'checked'
});

They expand the default options, which are the same except the custom checkboxClass option. https://github.com/fronteed/iCheck/blob/2.x-beta/icheck.js#L18-L52

Instead, you can set this option using the data attribute:

<input type="checkbox" data-checkedClass="icheckbox_flat-blue" class="icheck" id="rememberMe" name="rememberMe"  />

iCheck customizes all the .icheck selector elements by default https://github.com/fronteed/iCheck/blob/2.x-beta/icheck.js#L48

anotherZero commented 10 years ago

looks great, thanks!