I'm syncing queryParams with ember choices is what I have in mind.
- The user can select the parameter in ember.select -> queryParams should be updated.
The user copies / pastes the URL using some Param -on pageload request. Ember.select should show the corresponding option
The sortAscending property can be mapped to order. I can reach part 2. Now I am confused how to reach part 1 of
JSB i N
App.ApplicationController = Ember.Controller.extend({
queryParams: ['sortBy'],
sortBy: '',
selectedOption: { id: 2 },
options: [
{ id: 1, name: 'relevance', value: 'relevance' , order: true },
{ id: 2, name: 'First Name', value: 'firstName' , order: true }
],
sortByDidChange: function(){
options = this.get('options').findBy('value',this.get('sortBy'));
console.log('optionid = '+options.id );
this.set('selectedOption.id',options.id);
console.log('selectedoption = '+this.get('selectedOption.id'));
}.observes('sortBy'),
actions: {
change: function(){
this.set('selectedOption.id',2);
}
}
});
** UPDATES 2 **
sortBySelection: function(){
var sortByOptions= this.get('sortByOptions');
var selection = sortByOptions.findBy('value',this.get('sortBy')) || {id: 1} ;
return selection ;
}.property('sortBy'),
View
{{view Ember.Select
content=sortByOptions
optionLabelPath='content.name'
optionValuePath='content.id'
selection = sortBySelection
classNames='pull-right'
}}
mixin sortBySelection Ember.Select sortByOptions (.. {id: 1, value: price, order: true}). undefined, Ember.select . (I) ,
sortByOptionsDidChange: function(){
console.log(this.get('sortBySelection'));
var sortBy = this.get('sortBySelection.value') || 'relevance';
var OrderBy = this.get('sortBySelection.order') && true;
this.set('sortProperties',[sortBy]);
this.set('sortAscending',OrderBy);
}.observes('sortBySelection'),
** U P D A T E S 1 **
, , . , . , .