lessless
lessless

Reputation: 896

Ember.js: how to set associated model via select box

My app has two models Url and UrlType and I want to select UrlType via select box. How do I do that? Here is the jsbin where I tried to reproduce the scenario, though this.get('store') do not work :( But the idea must be pretty clear.

http://emberjs.jsbin.com/nefas/6/edit

Upvotes: 1

Views: 65

Answers (2)

Vysakh Sreenivasan
Vysakh Sreenivasan

Reputation: 1729

Few things with your jsbin.

  • this.store din not work as you have not mentioned your adapter like this

     App.ApplicationAdapter = DS.FixtureAdapter;
    
  • You din not return in the model return.

Though you have got around what you wanted, I have made a jsbin that might have what you want. http://emberjs.jsbin.com/saxuy/1/edit

Update

http://emberjs.jsbin.com/saxuy/6/edit

You could set the url_type attribute of your url model directly like this in your template.

{{view Ember.Select content=urlTypes optionLabelPath='content.caption' selection=url_type}}

If there was a url_type set for the model, it will be the selected option.

Upvotes: 1

Kingpin2k
Kingpin2k

Reputation: 47367

Looks like your logic is working just fine

http://emberjs.jsbin.com/nefas/12/edit

Upvotes: 0

Related Questions