Fixture Adapter filtering question


Hi all, I’m new to EmberJS and didn’t do a lot of web development lately (in fact I switched to other technologies in the past when it was suggested to disable javascript in your browser :D).

However, I’m back enjoying Ember which is a pleasure to work with. I’m currently writing an application relying on fixture data (REST API will follow) which I have some problems or misunderstandings with.

I’m displaying a lot of products in different categories and my index route e.g. should present only products containing a special flag.

TM.IndexRoute = Ember.Route.extend({
model: function() {
	return TM.Product.all().filter(function(item){
						return item.get('featured') === 1;

My problem: After loading the index route for the first time the model is empty. Switching to a different route and back to the index route displays the data as expected. I have the same issue with several filtering and no clue why this happens. It always works instantly without the filter.

I’d like to add, that my javascript skills are very basic, so this problem may be “self made”.

thx in advance.


What version of emberjs and ember-data are you using currently?


ember 1.0.0-rc.2 and ember-data commit 5fd6d65 from 2013-03-28 (revison 12). Had the same behavior with revision 11 from the starter kit.


I think I found my problem. The .find() method is not returning full objects synchronously, they get populated asynchronously, even with the fixture adapter - which makes sense after all.

I guess the correct solution would be returning TM.Product.find({featured: 1}) as my model - which is not implemented within the fixture adapter. Rev. 11 of ember-data didn’t give me a warning about that but rev 12 fortunately does.

Finally my wrong expectation of .find() on the fixture adapter returning results synchronously caused my problem.


Just a follow up, providing the model works now as expected but I had to “preload” all products by adding TM.Product.find() to the ApplicationController’s init method. I assume this is an issue with the fixture adapter and I’ll get back to this issue after connecting the REST backend.


@mgratzer, what was the resolution? Did this take care of itself after you plugged this into a REST Adapter?