I have a simple Ember application where I have an input box, two select boxes and a button. I can access the value of the input box in the method \"doSearch\", but not the v
Extend your ApplicationController
with two new variables to hold the selected values:
App.ApplicationController = Ember.ArrayController.extend({
selectedContentType: null,
selectedDate: null,
...
});
and use the selectionBinding
property of the Ember.Select class to bind to those variables
Content Type:
{{view Ember.Select
content=selectContentType
optionValuePath="content.value"
optionLabelPath="content.label"
selectionBinding=selectedContentType}}
Date:
{{view Ember.Select
content=selectDate
optionValuePath="content.value"
optionLabelPath="content.label"
selectionBinding=selectedDate}}
then you can later access them easily with:
App.ApplicationController = Ember.ArrayController.extend({
selectedContentType: null,
selectedDate: null,
...
actions: {
doSearch: function () {
var selectedDate = this.get('selectedDate.value');
console.log( selectedDate );
var selectedType = this.get('selectedContentType.value');
console.log( selectedType );
}
}
});
Hope it helps.