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

Select

Extends:

DOMElement → Select

Class used to handle select elements (<select>).

Example:

// Given the following HTML select element:
//   <select id="fx" name="fx">
//     <option value="1">Option 1</option>
//     <option value="2">Option 2</option>
//     <option value="3">Option 3</option>
//   </select>
var fx = new Select("fx", function(val) {
 console.log(val);
});

Constructor Summary

Public Constructor
public

constructor(id: string, onChange: function)

Member Summary

Public Members
public

Callback function for when the selected option changes.

public

Current option selected.

Method Summary

Public Methods
public

setOptions(options: Object, select: Number)

Sets the options for the select element.

Inherited Summary

From class DOMElement
public

Stores if the element is enabled or disabled.

public

jQuery reference to the element.

public

enabled(state: boolean)

Enable or disable the DOM element.

Public Constructors

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

Override:

DOMElement#constructor

Params:

NameTypeAttributeDescription
id string

HTML id of the select element.

onChange function

Callback function for when the selected option changes.

Public Members

public onChange: function source

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

public value: number source

Current option selected.

Public Methods

public setOptions(options: Object, select: Number) source

Sets the options for the select element.

Params:

NameTypeAttributeDescription
options Object

Object that will define the options in the select element.

select Number

Key of the option to select.