-
Notifications
You must be signed in to change notification settings - Fork 4
Switch
Eric edited this page Dec 10, 2022
·
19 revisions
Switch
is a simple switch that toggles between two values.
Extends
Uxi, Touch
{"selector:Switch":{CONFIG}}
let config = {
el:_SELECTOR_, //Required, selector
data:[{label:_STRING_, value:*}, {label:_STRING_, value:*}], //Defaults to [{label:'OFF', value:0}, {label:'ON', value:1}] //Optional
labels:true|false, //Optional, display labels, default to true
enabled:true|false, //Optional, defaults to true
name:_STRING_, //Optional
value:*, //The current value
speed:_INT_ //Optional, animation speed, defaults to 250ms
};
let switch = new OGX.Switch(config);
To create from an OML node, from an object extending Uxi
let node = {};
node["#myDiv:Switch"] = config;
OGX.OML.render(this, OML);
You can also create a Switch on the fly, at runtime, from an object extending Uxi
let swt = this.create('Switch', config);
or independently
let swt = OGX.Object.create('Switch', config);
In any case, you can either set the current value via the config object, or via the
data-value
attribute of your container element. The attribute will be converted to value via theOGX.Data.stringToVal
method then removed from the element.
<div id="mySwitch" data-value="myValue"></div>
switch.toggle();
switch.enable();
switch.disable();
OGX.Switch.CHANGE
switch.val(); //Retrieve value
switch.val(__value, __trigger); //Set value, trigger 'change' is true
switch.destroy();
- Welcome
- Changelog
- Structure
- Configuration
- Getting started
- CLI
- Poly
- Core
- Templating
- Routing
- Controllers
- Components
- Extra Components
- Helpers
- Styling
- Debugging