drgullin / icheck

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

checking checked state of check box gives flipped result #426

Closed kapyaar closed 3 years ago

kapyaar commented 3 years ago

When I use "IfClicked" to find the current state of a checkbox, the result is flipped. ie, shows unchecked when it is checked, and vice versa,

Just to show what I am talking about, I downloaded the latest git version, and put it on my domain. Here is the link.

http://watchdog15.com/icheck-103/demo/index.html

Scroll down to flat skin section. I have the first two check boxes display their checked state right next to them. One is unchecked and the other is checked by default, to show that it does not seem to make any difference. The result seems to show the opposite of the real state.

jquery code is around line#1165 if you want to see that from the source.

                       $('input[name="enableTest"]').on('ifClicked', function(event){ 
                //console.log(this.prop('checked'));
                if($(this).prop('checked')){
                    $('#chkbx1State').html("checked");
                     console.log('checked');
                  }else{
                    $('#chkbx1State').html("Not checked");
                     console.log('not checked');
                  }             
              });

Is there an "icheck" way to check this? I searched a lot, and saw few other mentions similar to this, but could not quite figure it out. Thanks for any hints.

kapyaar commented 3 years ago

Alright, I think I got a working solution. Instead of ifClicked, IfChecked seems to give correct response. Still curious as to why ifClicked gives flipped prop readings. I will keep this open for a short bit in case someone may see this and enlighten, otherwise I will close this issue.