Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to the <a href="http://emberjs.com/guides/models/finding-models/" rel="nofollow">Ember Data docs</a> regarding queries:</p> <blockquote> <p>You can query the server by passing a hash to find().</p> <p>The contents of the hash is opaque to Ember Data; it is up to your server to interpret it and return a list of records.</p> </blockquote> <p>If you want client-side filtering you can use the <code>filter()</code> method of <code>Ember.Array</code>. This example displays a computed property that contains a subset of the original array contents. This computed array only shows items that match what is typed into the box.</p> <p><a href="http://jsbin.com/ixupad/216/edit" rel="nofollow">JSBin Example</a></p> <p>Javascript:</p> <pre><code>App = Ember.Application.create({}); App.IndexRoute = Ember.Route.extend({ setupController: function(controller) { controller.set('content', [ Ember.Object.create({name: 'Joe'}), Ember.Object.create({name: 'Frank'}), Ember.Object.create({name: 'John'}), Ember.Object.create({name: 'Billy'}), Ember.Object.create({name: 'John'}), Ember.Object.create({name: 'Johnny'}) ]); } }); App.IndexController = Ember.ArrayController.extend({ content: [], filter: "", filteredContent: function() { var filter = this.get('filter'); return this.get('content').filter(function(item, index, enumerable){ return item.get('name').toLowerCase().match(filter.toLowerCase()); }); }.property('filter', 'content.@each') }); </code></pre> <p>Handlebars:</p> <pre><code>&lt;script type="text/x-handlebars" data-template-name="index"&gt; &lt;h2&gt;Index Content:&lt;/h2&gt; &lt;span&gt;Filter: &lt;/span&gt;{{view Ember.TextField valueBinding=filter}} &lt;ul&gt; {{#each item in filteredContent}} &lt;li&gt;{{item.name}}&lt;/li&gt; {{/each}} &lt;/ul&gt; &lt;/script&gt; </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