mdbootstrap / bootstrap-toggle-buttons

Bootstrap-toggle-buttons has moved to https://github.com/nostalgiaz/bootstrap-switch
https://github.com/nostalgiaz/bootstrap-switch
Apache License 2.0
1.02k stars 92 forks source link

Not matching the checkbox underneath #8

Closed ghost closed 11 years ago

ghost commented 11 years ago

It doesn't seem that the bootstrap toggle button is matching whether the checkbox is checked or not.

Is this a deliberate design choice?

Eg. when the checkbox is checked the toggle button is showing OFF.

nostalgiaz commented 11 years ago

Can you give me an example?

You are trying to use this code or something similar?

$('#myCheckBox').attr('checked', true);
ghost commented 11 years ago

Yeah, you are very clever :)

I used that one but toggle button didn't react to the change.

How should I do?

Wingy

On Wed, Sep 12, 2012 at 7:31 PM, Mattia Larentis notifications@github.comwrote:

Can you give me an example?

You are trying to use this code or something similar?

$('#myCheckBox').attr('checked', true);

— Reply to this email directly or view it on GitHubhttps://github.com/nostalgiaz/bootstrap-toggle-buttons/issues/8#issuecomment-8502946.

nostalgiaz commented 11 years ago

The problem is that this code does not raise an event and then the toggle button does not change state.

$('#myCheckBox').attr('checked', true);

then you should use something like this

var $myCheckBox = $('#myCheckBox') 
$myCheckBox.attr('checked', ! $myCheckBox.is(':checked')).trigger('change');