olance / jQuery-switchButton

jQuery UI iPhone-like switch button
111 stars 102 forks source link

Callback? #22

Open batbayar-su opened 8 years ago

batbayar-su commented 8 years ago

Is there any callback option?

batbayar-su commented 8 years ago

Right now i'm using like this

$("#choices .switch-button-button, #choices .switch-button-background").click(function(e) {
    if($('#choices .switch-button-background').hasClass('checked')) {
      //do something
    } else {
      //do something
    }
});
olance commented 8 years ago

Hi, unfortunately I don't have much time to maintain this old plugin and it's been really a long time since I used it...

If I am not mistaken, you should be able to use $('#myinput').change(function(e) { ... }) where #myinput is the checkbox that you initialized the plugin with!

ghost commented 8 years ago

Make change " input type="checkbox" value="1" onchange="if(this.checked){ alert('a'); }else {alert('b')}"