Skip to content

Select component for Ember based on the native html select element.

License

Notifications You must be signed in to change notification settings

enspandi/emberx-select

 
 

Repository files navigation

emberx-select

npm version Ember Observer Score Build Status

A Select component based on the native html select.

Why a select component? Because Ember.Select is hard to use, and really, all you want to do is just use a <select> tag dammit. The only difference is that you want value of the options to be any object and not just a string.

By allowing arbitrary html to appear in the template of the select element, you can use it just like you would normally. This means things like having <optgroup> tags inside your select, or even plain old <option> elements to represent things like empty values.

XSelect thinly wraps a native element so that it can be object and binding aware. It is used in conjuction with the x-option component to construct select boxes. E.g. {{#x-select value=bob action="selectPerson"}} {{#x-option value=fred}}Fred Flintstone{{/x-option}} {{#x-option value=bob}}Bob Newhart{{/x-option}} {{/x-select}} the options are always up to date, so that when the object bound to value changes, the corresponding option becomes selected. Whenever the select tag receives a change event, it will fire action Multiselect As of version 1.1.0, emberx-select supports the multiple option. This means you can pass an array as its value, and it will set its selections directly on that array. {{#x-select value=selections multiple=true action="selectionsChanged"}} {{#x-option value=fred}}Fred Flintstone{{/x-option}} {{#x-option value=bob}}Bob Newhart{{/x-option}} {{#x-option value=andrew}}Andrew WK{{/x-option}} {{/x-select}} The selections array will be initialized to an empty array if not present. Heads Up! This will mutate the contents of your value array as the user changes their selections. This can lead to strange behavior and inconsistencies if you are using computed arrays and/or ember-data hasMany relationships. Just remember, you can't go wrong if you use just a simple array. EmberX emberx-select is part of the "missing components of ember" collectively known as emberx. See also: emberx-slider Installation ember install:addon emberx-select Running Tests ember test ember test --server

About

Select component for Ember based on the native html select element.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 87.0%
  • HTML 7.6%
  • Handlebars 5.2%
  • CSS 0.2%