olance / jQuery-switchButton

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

Triggering a Refresh #7

Open HoecusPocus opened 11 years ago

HoecusPocus commented 11 years ago

Hi there,

I've got a form that hides in a jQuery Dialog, which I copy values to based on a click of an element in the page.

I set the value of the inputs (there is an input[type=checkbox] and a hidden - this is an MVC website) to have the checked / value=true, depending on the hidden fields of the clicked item.

However the switchButton doesn't seem to update / switch itself over when setting the underlying input field. Is there a way to trigger this?

Thanks, Ben

ErwinM commented 10 years ago

I am need of this functionality as well. Is it possible to trigger a refresh?

My use case:

Switching the button triggers a dialog. If the user were to cancel the dialog I need to move the button back to its original position.

No idea how to do this though. Changing the :checked state underlying check box does not change the button..

olance commented 10 years ago

Guys, I'm sorry I don't remember having seen this issue at all :\ Let me look at @ErwinM PR and I'll try to act quickly on it!

madhukumars17 commented 7 years ago

Hi guys,

To change the state of :checked (for toggling between on and off label) you can use the class "switch-button-label off"

html snippet: <div id="switch-button-toggle"> <input type="checkbox" class="switch-button"/> </div>

js snippet: $("#switch-button-toggle [class='switch-button-label off']").click();