-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clicking label not working as expected #312
Comments
I have updated the code to show something i have noticed: http://jsfiddle.net/plribeiro3000/aL835/3/ If you look at the console you will the event being triggered twice. Is this behavior expected? |
good morning @plribeiro3000, |
Good morning @LostCrew ! |
The link is : http://cdn2.plribeiro3000.com.br/bootstrap-switch.js =) |
I found that https://github.com/nostalgiaz/bootstrap-switch/blob/master/src/coffee/bootstrap-switch.coffee#L236 is triggering the event again if the input is a radio and the event did not turned the switch on. Is that the behavior expected? or should it act like normal radio buttons? |
My bad, it acts like a normal radio button by doing nothing if you click on a already selected option. |
@plribeiro3000 can you update the bootstrap switch source of the jsfiddle according to the latest develop branch changes? i made a couple of optimizations and they might have implicitly solved this issue. thanks. |
I have updated the source at plribeiro3000.com.br, but just in case i have update the jsfiddle as well. New link : http://jsfiddle.net/plribeiro3000/aL835/6/ But the behavior still exists. |
After hours of debugging JavaScript in firebug, I found that I can fix this by removing the 'for' attribute from the label: var checkbox = $("<input type='checkbox' id='MyCheckbox'>").prependTo( $("body") );
checkbox.bootstrapSwitch();
var bootstrapSwitch = checkbox.data('bootstrap-switch');
bootstrapSwitch.$label.removeAttr("for"); Clicking a label with attribute for="MyCheckbox" will be handled by Firefox. Removing removing the 'for' attribute from the label stops Firefox from changing the checkbox value again. |
@psychonelo @plribeiro3000 thank you very much for the collaboration. feel free to give the updated |
Hi. The new version @LostCrew release handles clicks on the label. But im facing a weird behavior, if the label is on the right side, it does not change the button, but does trigger the event and everything else work as expected.
I have a simple example on fiddle : http://jsfiddle.net/plribeiro3000/aL835/1/
The text was updated successfully, but these errors were encountered: