Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In your controller you can do something like this:</p> <pre><code>indications1a: Ember.A(), indications1b: Ember.A(), loadIndications: function (name, parentId) { var self = this; $.connection.ccprIndicationsToRevalidation.server.getAllByParentId(parentId) .done(function (result) { self.set("indications%@".fmt(name), result); self.checkIfChildInChildren(name); }); }, loadChildIndications: function (name1, name2) { var parent = this.get('content.indication%@'.fmt(name1)), parents = this.get('indications%@'.fmt(name1)), childs = this.get('indications%@'.fmt(name2)); childs.clear(); if (!Em.isEmpty(parent) &amp;&amp; !Ember.isEmpty(parents)) { var indication = null; parents.every(function (item) { if (Em.isEqual(Ember.get(item, 'id'), parent)) { indication = item; return false; } return true; }); if (!Ember.isEmpty(Ember.get(indication, 'hasChildren'))) { this.loadIndications(name2, indication.id); } else { this.set('content.indication%@'.fmt(name2), 0); } } }, checkIfChildInChildren: function (name) { var child = this.get('content.indication%@'.fmt(name)), childs = this.get('indications%@'.fmt(name)); var found = false; childs.every(function (item) { if (Em.isEqual(Em.get(item, 'id'), child)) { found = true; return false; } return true; }); if (!found) { this.set('content.indication%@'.fmt(name), 0); } }, indicationToRevalidation1aChanged: function () { this.loadChildIndications('1a', '1b'); }.observes('content.indication1a', 'indications1a.length'), hasNoIndications1b: function() { return this.get('indications1b.length') === 0; }.property('indications1b.length'), </code></pre> <p>in the setupController of the route</p> <pre><code>controller.get('indications1a').clear(); controller.get('indications1b').clear(); controller.loadIndications('1a', null); </code></pre> <p>the handlebars:</p> <pre><code> {{view Bootstrap.Forms.Select label=false contentBinding="controller.indications1a" optionLabelPath="content.description" optionValuePath="content.id" valueBinding="controller.content.indication1a"}} {{view Bootstrap.Forms.Select label=false contentBinding="controller.indications1b" optionLabelPath="content.description" optionValuePath="content.id" disabledBinding="controller.hasNoIndications1b" valueBinding="controller.content.indication1b"}} </code></pre>
 

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