Irshu
Irshu

Reputation: 8436

Ember select ValueBinding not working

I have a controller like this,

 App.ViewerController = Ember.ObjectController.extend({
          selectedUsers: [],
          users: null
});

users gets filled at the route.

However when i declare a select multiple in my template,

{{view Ember.Select
contentBinding="controller.users"
multiple="true"
class="input-large"
valueBinding="controller.selectedUsers"
optionLabelPath="content.userId"
optionValuePath="content.userId"
}}

the selectedUsers is not selected in the view. what am i doing wrong? I capture this from the Ember Inspector for selectedUsers right before the Ember.Select is called,

0: "Irshu"
1: " Yehuda"
@each: (...)
get @each: function () {
set @each: function (value) {
__ember1389253247784_meta: Meta
length: 2
__proto__: Array[0]

But once Ember.Select is called, selectedUsers is then undefined. Am i missing something?Please help...

Upvotes: 0

Views: 2215

Answers (2)

koanima
koanima

Reputation: 577

I think you need to get 'selectedUsers'. For example, if you are using the selection in an action in your controller, then you would access the selection with this.get('selectedUsers'), like this:

App.ViewerController = Ember.ObjectController.extend({
   selectedUsers: ['George'],
   users: ['George', 'Samantha', 'Miguel'],
   actions: {
     yourAction: function(){
       console.log(this.get('selectedUsers'))
       // the rest of your action here
     }
   }
});

Upvotes: 0

jacquard
jacquard

Reputation: 1307

You have to use the selection option. updated bin

Upvotes: 4

Related Questions