Note that there are some explanatory texts on larger screens.

plurals
  1. POselect dropdown with ember
    primarykey
    data
    text
    <p>I'm trying to produce a select input and pass the selected object to the change event on the view. The ember contact example uses a <code>&lt;ul&gt;</code> but with a select the view needs to be outside the each otherwise the change even isn't fired.</p> <p>Here is the view js:</p> <pre><code>App.SelectView = Ember.View.extend({ change: function(e) { //event for select var content = this.get('content'); console.log(content); App.selectedWidgetController.set('content', [content]); }, click: function(e) { //event for ul var content = this.get('content'); console.log(content); App.selectedWidgetController.set('content', [content]); } }); </code></pre> <p>The <code>ul</code> from the example works:</p> <pre><code>&lt;ul&gt; {{#each App.widgetController.content}} {{#view App.SelectView contentBinding="this"}} &lt;li&gt;{{content.name}}&lt;/li&gt; {{/view}} {{/each}} &lt;/ul&gt; </code></pre> <p>But if I replace html directly, the change event isn't fired (which makes sense)</p> <pre><code>&lt;select&gt; {{#each App.widgetController.content}} {{#view App.SelectView contentBinding="this"}} &lt;option&gt;{{content.name}}&lt;/option&gt; {{/view}} {{/each}} &lt;/select&gt; </code></pre> <p>So I guess the select has to be wrapped in the view.. in which case how do I pass the relevant object?... This code results in the entire array being passed:</p> <pre><code>{{#view App.select_view contentBinding="App.widgetController.content"}} &lt;select&gt; {{#each App.widgetController.content}} &lt;option&gt;{{name}}&lt;/option&gt; {{/each}} &lt;/select&gt; {{/view}} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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