Class: ToggleView

ToggleView()

A configurable two-option toggle with optional description area. Uses the "button group" or "segmented control" UI pattern, which indicates mutually exclusive options more clearly than switch toggles or radio buttons.

Screenshot

Constructor

new ToggleView()

Since:
  • 2.34.0
Source:

Extends

  • Backbone.View

Members

className

Source:

Methods

addTooltips()

Initialize option tooltips using the Formantic UI popup module.
Source:

disable()

Disable the toggle
Source:

enable()

Enable the toggle
Source:

events()

Source:

getOptionByKey(valueKey) → {ToggleOption|undefined}

Get an option by its DOM key.
Parameters:
Name Type Description
valueKey string String key from DOM data attribute.
Source:
Returns:
The matching option, or undefined if not found.
Type
ToggleOption | undefined

initialize(options)

Parameters:
Name Type Description
options object Configuration options
Properties
Name Type Attributes Description
options Array.<ToggleOption> Array of exactly two options
selected * <optional>
The value of the initially selected option
showDescription boolean <optional>
Whether to show description below toggle. True by default.
tooltipSettings object | boolean <optional>
Custom settings for Formantic UI popup tooltips. Set to false to disable tooltips entirely.
Source:

onToggle(e)

Handles toggle option click
Parameters:
Name Type Description
e MouseEvent Click event
Source:

remove()

Source:

removeTooltips()

Remove Formantic UI popup instances from this toggle's options.
Source:

render() → {ToggleView}

Render the toggle UI
Source:
Returns:
This view instance
Type
ToggleView

toggleDisabled(disabled)

Enable or disable the toggle
Parameters:
Name Type Description
disabled boolean Whether the toggle should be disabled
Source:

updateButtonsAndDescription(selectedValue)

Updates the toggle buttons' active state and icons
Parameters:
Name Type Description
selectedValue * The value of the currently selected option
Source: