mardi 5 avril 2016

Ember.js How to send values from multiple select with RESTAdapter

I got content like this

App.companies = [
  Ember.Object.create({id:'c1',name:'Company 1'}),
  Ember.Object.create({id:'c2',name:'Company 2'}),
  Ember.Object.create({id:'c3',name:'Company 3'}),
  Ember.Object.create({id:'c4',name:'Company 4'})
];

template

{{view select
    contentBinding="App.companies"
    optionValuePath="content.id"
    optionLabelPath="content.name"
    valueBinding="company"
    required="true"
    multiple="true"
    size="5"                
}}

controller (cut)

ItemsApp.AddItemController = Ember.ObjectController.extend({
    actions:{
        submitAction : function(){                                      

            var company = this.get('company');              

            var postData = {            
                company:company,            
            }

            var item = store.createRecord('item',postData);
            item.save().then(t).catch(e);                        
        }   
    }
});

With single value everything works ok, but i have no idea how to send multiple values

Ember v1.8.1




Aucun commentaire:

Enregistrer un commentaire