Wiki

Clone wiki

Metro Toggle / Home

Metro Toggle

This is a small jQuery plugin that allows you to transform an element into a Windows Phone 7 style toggle control.

To use this library, simply import the script:

<script type="text/javascript" src="metroToggle.js"></script>

Then, select elements and initialize:

<span class="something"></span>

<script type="text/javascript"> $(document).ready(function() { $(".something").metroToggle(); }); </script>

# Methods #

getValue() ##

Returns the boolean value of the toggle control.

setMetroToggle(value) ##

Sets the boolean value of the toggle control.

toggleMetroToggleValue() ##

Inverts the current value of the toggle control.

toggleReadOnlyMetroToggle() ##

Sets the toggle control to be read only.

enableMetroToggle() ##

Enables the toggle control.

disableMetroToggle() ##

Disables the toggle control.

toggleEnabledMetroToggle() ##

Inverts the enabled state of the toggle control.

# Updating Hidden Input Elements #

The metroToggle control supports updating a hidden input element. To enable this feature, include the ID of the element using a `for` attribute:

<span class="something" for="a-hidden-input"></span> <input type="hidden" id="a-hidden-input" value="false" />

Updated