drgullin / icheck

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

onclick events, related with the checkboxes, not work... #52

Closed giovkanata closed 11 years ago

giovkanata commented 11 years ago

This is a great plugin I'm trying to implement on my little project (in local), but after some attempts (and after carefully read the relative docs) I would need a little help for a simple questions. Following example is only for explaining purposes (really I've a hundred checkboxes on my form and all them are related to their "hidden div"), I've a simple "onclick" event on a checkbox (to shows/hides a div chained to it): <input name="some_name" id="some_name" value="1" type="checkbox" onclick="if(this.checked) { jQuery('#hidden_div').slideToggle(800); } else { jQuery('#hidden_div').hide(400); }" /> When an user clicking the checkbox, the validation tool (for example) recognises the checkbox as "checked" but the onclick event doesn't fire.

To avoid to rebuilt all conditions in the "onclick" events it's possible to read dinamically all setted conditions to then fire them with a iCheck callback? (using for example: .attribute('onclick')?) or is a bad idea?. I'm new on jQuery (I've started to study it only a few days ago) and any help will be really appreciate.

drgullin commented 11 years ago

You can use ifToggled callback instead:

$('input:checkbox').on('ifToggled', function() {
  // do something
});

https://github.com/fronteed/iCheck#callbacks

Next version will support click handler on inputs.

cdiazr commented 9 years ago

Hi, when is coming next version which will support click handler on inputs? I cannot to write code for each event click on differentes radio buttons. Only recognise one. Maybe a longer explanation on plugin's documentation with different examples of use for each callback could be awesome.

smemamian commented 8 years ago

using this library without support click handler maybe you'd find it dull.