Note that there are some explanatory texts on larger screens.

plurals
  1. POLearning Ember.js- How Would I do this?
    primarykey
    data
    text
    <p>To learn Ember.js I started writing a small <a href="https://home.mythli.net/web/ember/bookmarker/" rel="nofollow">bookmark application</a>. Bookmarks with the selected label should be displayed in the bottom box.</p> <p><strong>Template:</strong></p> <pre><code>... {{#each itemController="label"}} &lt;li&gt; &lt;a href="#" {{bind-attr class=":label active:label-primary:label-default"}} {{action 'findLinks'}}&gt;{{name}}&lt;/a&gt; &lt;/li&gt; {{/each}} ... {{#each links}} &lt;li&gt;{{name}}&lt;/li&gt; {{/each}} ... </code></pre> <p><strong>App.LabelController:</strong></p> <pre><code>... App.LabelController = Ember.ObjectController.extend({ needs: ["list"], active: false, actions: { findLinks: function() { var listController = this.get('controllers.list'); this.toggleProperty('active'); listController.set('model', this.get('store').find('link')); } } }); ... </code></pre> <p><strong>Label Data:</strong></p> <pre><code>App.Label = DS.Model.extend({ links: DS.hasMany('link'), name: DS.attr('string'), color: DS.attr('string') }); App.Label.FIXTURES = [ { id: 1, name: 'Develop', color: 'blue' }, ... ]; </code></pre> <p><strong>Link Data:</strong></p> <pre><code>App.Link = DS.Model.extend({ labels: DS.hasMany('label'), name: DS.attr(), url: DS.attr() }); App.Link.FIXTURES = [ { id: 1, name: 'Google', url: 'http://google.com', labels: [1] }, ... ]; </code></pre> <p>The issue I have now is that setting the model in LabelController doesn't update the list of links. I also doubt that this is the right approuch.</p> <p>How would you do such a thing in Ember?</p> <p>Edit: <a href="http://jsbin.com/Ovuw/81/edit" rel="nofollow">http://jsbin.com/Ovuw/81/edit</a></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.
    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