Home Reference Source
import {Options} from 'newton-lib/src/dom/dom.js'
public class | source

Options

Class used to handle a set of multiple radio buttons (<input type="radio">).

Example:

// Given the following set of HTML radio buttons:
//   <input type="radio" name="graph_type" value="pos">
//   <input type="radio" name="graph_type" value="vel">
//   <input type="radio" name="graph_type" value="accel">
var graph_type = new Options("graph_type", function(val) {
   console.log(val);
});

Constructor Summary

Public Constructor
public

constructor(name: string, onChange: function)

Member Summary

Public Members
public

Sets the id of the input using the name as an argument.

public

jQuery reference to the input.

public

Callback function for when a radio button is selected.

public

Value of the currently selected radio option.

Method Summary

Public Methods
public

enabled(state: boolean)

Enables or disables the radio options.

public

select(value: string)

Selects a radio button using its value.

Public Constructors

public constructor(name: string, onChange: function) source

Params:

NameTypeAttributeDescription
name string

Name of the radio buttons.

onChange function

Callback function for when any of the radio buttons changes state.

Public Members

public name: string source

Sets the id of the input using the name as an argument. This id is then used to obtain the jQuery object of the input.

public obj: object source

jQuery reference to the input.

public onChange: function source

Callback function for when a radio button is selected. The value of the selected radio button is passed to the callback function as a parameter.

public value: string source

Value of the currently selected radio option.

Public Methods

public enabled(state: boolean) source

Enables or disables the radio options.

Params:

NameTypeAttributeDescription
state boolean

Desired state of the element.

public select(value: string) source

Selects a radio button using its value.

Params:

NameTypeAttributeDescription
value string

Value of the radio button to select.