Skip to content

Commit b8e9821

Browse files
queenvictoriamike-north
authored andcommitted
feat: trigger actions from md-select. (#716)
1 parent 42a2a63 commit b8e9821

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

addon/components/md-select.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ export default MaterializeInputField.extend({
5151
// jscs: enable
5252
},
5353

54+
actions: {
55+
optionSelected(e) {
56+
const target = e.target;
57+
if (!this.get('isDisabled')) {
58+
if (this.get('action')) {
59+
this.sendAction('action', target.value);
60+
}
61+
else {
62+
this.set('value', target.value)
63+
}
64+
}
65+
}
66+
},
67+
5468
// TODO: this could be converted to a computed property, returning a string
5569
// that is bound to the class attribute of the inputSelector
5670
errorsDidChange: observer('errors', function() {

addon/templates/components/md-select.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<label id="{{id}}" class="active">{{label}}</label>
22

3-
<select onchange={{action (mut value) value="target.value"}}
3+
<select onchange={{action 'optionSelected'}}
44
class="{{if validate 'validate'}} {{if errors 'invalid' 'valid'}}"
55
disabled={{if disabled "true"}}>
66
{{#if prompt}}

0 commit comments

Comments
 (0)