Class: ComboBox

ComboBox

new ComboBox(options, data)

Traditional select element replacement for Spark Framework.

Parameters:
Name Type Argument Description
options Object <optional>

Class options.

data Array <optional>

Combobox item data.

Source:

Extends

Members

<static> EventTypes :string

Event types map

Type:
  • string
Properties:
Name Type Default Description
SELECTED string selected
Source:

Methods

addClass(cssClass)

Adds new class name to element.

Parameters:
Name Type Description
cssClass string

New class name for the element.

Inherited From:
Source:

addItem(item, index)

If item is an instance of goog.ui.MenuItem it will be added to menu otherwise the data is consistent enough a MenuItem instance will be created and added to menu. index parameter is optional. If it's not passed item will be appended at the end of the menu otherwise it will be appended into that position.

Parameters:
Name Type Argument Description
item goog.ui.MenuItem | Object

MenuItem instance or plain object. If the item is an instanceof goog.ui.MenuItem then it will be added to menu. If it's just an object and it has titleField and valueField in it, a goog.ui.Menu instance will be taken on the fly and added to the menu.

index number <optional>

Index to insert the menu item. It's optional, if you don't pass it the item will be appended at the end of the menu.

Source:

appendToDocumentBody()

Appends view into document's body.

Inherited From:
Source:

appendView(view)

Appends a new view into this view's element as a child.

Parameters:
Name Type Description
view spark.core.View

A spark.View instance to append.

Inherited From:
Source:

<private> bindEvents_()

This method is responsible from binding DOM events to the element of this view. It uses native DOM event names which is all lowercase. If your options has an event name and a callback function in events object View will bind and listen those events automatically.

Inherited From:
Source:

<private> createDomElement_()

Creates the element with the configuration passed to constructor.

Inherited From:
Source:

createItem(data, shouldAdd) → {goog.ui.MenuItem}

Creates and return a new goog.ui.MenuItem. You can use this method to create and add item to menu.

Parameters:
Name Type Argument Description
data Object

Data of the menu item. It should have valueField and titleField keys in it. Default keys are value and title.

shouldAdd boolean <optional>

If you pass should add as true, it will create and append the menu item at the end of the menu.

Source:
Returns:

Created menu item.

Type
goog.ui.MenuItem

<private> createItems_()

Creates all items using class data.

Source:

<private> createMenu_()

Creates menu and binds action event to menu to emit selected event.

Source:

destroy()

Destroys the view. It will unlisten all binded events including the DOM events and destroy all child views finally remove the element from document.

Inherited From:
Source:

disable()

Disable view.

Inherited From:
Source:

emit(eventName, data)

Dispatches an event and calls all listeners listening for events of this event. See also goog.events.Listenable.prototype.dispatchEvent

Parameters:
Name Type Argument Description
eventName string

Name of the event.

data * <optional>

Data which will passed to listeners

Inherited From:
Source:

enable()

Enable view.

Inherited From:
Source:

freeze()

Freezes object to prevent adding new properties, updating or deleting existing properties.

Inherited From:
Source:

getAttribute(name)

Native getAttribute wrapper.

Parameters:
Name Type Description
name string

Atrribute name.

Inherited From:
Source:

getChildren() → {Array.<spark.core.View>}

Returns the child views.

Inherited From:
Source:
Returns:

DOM element of this view.

Type
Array.<spark.core.View>

getClass() → {string}

Returns class name of the element.

Inherited From:
Source:
Returns:

Class name.

Type
string

getClassList() → {Array}

Returns class list of the element.

Inherited From:
Source:
Returns:

List of class names.

Type
Array

getCssClass(options, optionalClass)

Helper method to set css class to options set.

Parameters:
Name Type Argument Description
options Object

Class options.

optionalClass string <optional>

Optinal CSS class which will added to default.

Inherited From:
Source:

getData() → {*}

Returns class data.

Inherited From:
Source:
Returns:

Class data.

Type
*

getDomId() → {string|null}

Returns the DOM id if exists, otherwise it will return null.

Inherited From:
Source:
Returns:
Type
string | null

getElement() → {Element}

Returns the DOM element.

Inherited From:
Source:
Returns:

DOM element of this view.

Type
Element

getHeight() → {number}

Returns the height of the element.

Inherited From:
Source:
Returns:

View element height.

Type
number

getItemAt(index)

Returns the item at given index.

Parameters:
Name Type Description
index number

Item index to be removed.

Source:

getItemByValue(value)

Returns the item by given value.

Parameters:
Name Type Description
value string

Item value to be checked to find the item instance.

Source:

getItemData() → {Object}

Returns an item data.

Source:
Returns:
Type
Object

getItems()

Returns components items.

Source:

getName() → {string|null}

Return combobox name from options.

Source:
Returns:

Name of the combobox.

Type
string | null

getOption() → {*}

Returns value of a key in options object.

Inherited From:
Source:
Returns:

Value of key or null.

Type
*

getOptions() → {Object}

Returns all options object.

Inherited From:
Source:
Returns:

Options object.

Type
Object

getSelectedItem() → {goog.ui.MenuItem|null}

Returns selected item.

Source:
Returns:

Selected item.

Type
goog.ui.MenuItem | null

getSelectedItemData() → {Object|null}

Returns selected item data.

Source:
Returns:

Selected item data or null if not an item is selected.

Type
Object | null

getTitle()

Returns title element.

Source:

getUid() → {string}

Return unique id.

Inherited From:
Source:
Returns:

Unique id of this component.

Type
string

getValue() → {string}

Returns selected item's value.

Source:
Returns:

Selected item value.

Type
string

getWidth() → {number}

Returns the width of the element.

Inherited From:
Source:
Returns:

View element width.

Type
number

<private> handleSelection_()

Handles menu item selections. Emits selected event with the following data.

Source:

hasClass(cssClass) → {boolean}

Returns true if element has that class name.

Parameters:
Name Type Description
cssClass string

Name of the class which will be tested.

Inherited From:
Source:
Returns:

Whether element has a class name or not.

Type
boolean

hideMenu()

Hide menu.

Source:

isDestroyed() → {boolean}

Returns the object's destroy state.

Inherited From:
Source:
Returns:

Whether the object is destroyed or not.

Type
boolean

isDisabled()

Returns the current disabled state of the button.

Inherited From:
Source:

off()

Override Object::off to remove events binded to DOM element.

Inherited From:
Source:

on()

Override Object::on to support two way binding for DOM events.

Inherited From:
Source:

once()

Override Object::once to support two way binding for DOM events.

Inherited From:
Source:

removeAttribute(name)

Native removeAttribute wrapper.

Parameters:
Name Type Description
name string

Atrribute name.

Inherited From:
Source:

removeClass(cssClass)

Remove a class name from the element.

Parameters:
Name Type Description
cssClass string

Name of the class which will be removed.

Inherited From:
Source:

removeFromDocument() → {boolean}

Removes element from DOM if it is in DOM.

Inherited From:
Source:
Returns:

Whether element removed from document or not.

Type
boolean

removeItem(item)

Removes an item from menu.

Parameters:
Name Type Description
item goog.ui.MenuItem

Menu item to be removed.

Source:

removeItemAt(index)

Removes an item at the index.

Parameters:
Name Type Description
index number

Item index to be removed.

Source:

render(target)

Renders element into another View instance or a DOM element. Be aware that this method only appends the element of this class into another element. If the parent element is not in DOM, this method will not append the parent into DOM. Also you can use this method with renderTo option. If you pass renderTo as a View instance or DOM element, View will call render method by default.

Parameters:
Name Type Description
target spark.core.View | Element

Target view or element to be rendered.

Inherited From:
Source:

selectItem(item)

Selects an item in the menu.

Parameters:
Name Type Description
item goog.ui.MenuItem

Item to be selected.

Source:

selectItemAt(index) → {goog.ui.MenuItem|undefined}

Selects an item at the index.

Parameters:
Name Type Description
index number

Index to be used to select item.

Source:
Returns:

Returns item or undefined.

Type
goog.ui.MenuItem | undefined

selectItemByValue(value) → {goog.ui.MenuItem|undefined}

Selects an item with the given menu.

Parameters:
Name Type Description
value string

Value of the item to be selected.

Source:
Returns:

Returns item or undefined.

Type
goog.ui.MenuItem | undefined

setAttribute(name, value)

Native setAttribute wrapper.

Parameters:
Name Type Description
name string

Atrribute name.

value string

Attribute value.

Inherited From:
Source:

setClass(cssClass)

Sets the class name of element. This will override existing class names. Use @addClass if you want to add new class name to the element.

Parameters:
Name Type Description
cssClass string

Class name.

Inherited From:
Source:

setData(data)

Sets data of this class.

Parameters:
Name Type Description
data *

Data passed to class.

Inherited From:
Source:

setDomId(domId)

Sets DOM id.

Parameters:
Name Type Description
domId string

Id of the element.

Inherited From:
Source:

setHeight(height)

Sets height of this view's DOM element.

Parameters:
Name Type Description
height string | number

Height of the element. It can be string with 'px' value or just number.

Inherited From:
Source:

setOptions(options)

Sets options object of this class.

Parameters:
Name Type Description
options Object

Options object.

Inherited From:
Source:

setTemplate(template)

Basic templating support for Spark Framework. Currently templates can include variable tags like in Mustache templates. This can be changed in the future versions of the framework.

Variable tags should start with {{ and end with }}. That's borrowed from Mustache. Tags are not whitespace sensitive, so {{name}} and {{ name }} is the same.

Template should also be a function. Just make sure that function returns a string which will be the template. setTemplate will call the template function by passing the data of this View. So you can use class data in your template function. This will allow framework to easily integrate other template engines.

Spark Framework will use Closure Templates as it's default template engine. This is because to maintain the compiled code size advantage. I am also considering to support Mustache and Handlebar templates in Spark.

Parameters:
Name Type Argument Description
template string | function <optional>

HTML string of the element or function which will return the html string. Function will be called with class data. FIXME: Fix annotation for template variable, it should be {string|Function}

Inherited From:
Source:

<private> setUid_()

Sets uid.

Inherited From:
Source:

setValue(value) → {goog.ui.MenuItem|undefined}

Set value to select an item. Uses selectItemByValue. setValue is implemented because API should consistent with field components.

Parameters:
Name Type Description
value string

Value of the item to be selected.

Source:
Returns:

Returns item or undefined.

Type
goog.ui.MenuItem | undefined

setWidth(width)

Sets width of this view's DOM element.

Parameters:
Name Type Description
width string | number

Width of the element. It can be string with 'px' value or just number.

Inherited From:
Source:

showMenu()

Shows menu.

Source:

toggle()

Toggle view state. Disable if enabled, enable if disabled.

Inherited From:
Source:

toggleMenu()

Toggles menu visibility.

Source:
Spark Framework by Fatih Acet
Copyright © 2014 - Fatih Acet
Documentation generated by JSDoc 3.2.2 on 2015-07-19T22:09:30+00:00 using the DocStrap template.