Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to bind value form input select to attribute in controller
    primarykey
    data
    text
    <p>I try to bind value from input select to attribute "selectedValue" in controller.</p> <p>This is app.js</p> <pre><code>Food = Ember.Application.create(); Food.appsController = Ember.Object.create({ selectedValue: "" }); Food.Todo = Ember.Object.extend({ title: null, value: null }); Food.FoodController = Ember.ArrayProxy.create({ content: [] }); Food.FoodController.pushObject(Food.Todo.create({title:"a", value:"1"})); Food.FoodController.pushObject(Food.Todo.create({title:"b", value:"2"})); Food.FoodController.pushObject(Food.Todo.create({title:"c", value:"3"})); </code></pre> <p>This is index.html</p> <pre><code>{{#collection contentBinding="Todos.todosController" tagName="select" itemClassBinding="content.isDone"}} {{content.title}} {{/collection}} </code></pre> <p>Output look like this</p> <pre><code>&lt;select id="ember180" class="ember-view"&gt; &lt;option id="ember192" class="ember-view"&gt; &lt;script id="metamorph-0-start" type="text/x-placeholder"&gt;&lt;/script&gt; a &lt;script id="metamorph-0-end" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;/option&gt; &lt;option id="ember196" class="ember-view"&gt; &lt;script id="metamorph-1-start" type="text/x-placeholder"&gt;&lt;/script&gt; b &lt;script id="metamorph-1-end" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;/option&gt; &lt;option id="ember200" class="ember-view"&gt; &lt;script id="metamorph-2-start" type="text/x-placeholder"&gt;&lt;/script&gt; c &lt;script id="metamorph-2-end" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;/option&gt; &lt;/select&gt; </code></pre> <p>I have no idea how to add value to option and how to binding selected value back to controller. Is this possible to do in Emberjs?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload