简体   繁体   中英

Ember.js find with plain object is not working

I use Ember.js to get items like this:

App.MyData.find()

And to get item like this:

App.MyData.find(itemId)

And then I use filter and return it in model function like this:

App.MyRoute = Ember.Route.extend({   
    model: function()   {
        return App.MyData.find().filter(function(a)
        {
            return a.get('desc') != null;
        });
    } 
});

And it's working just fine.

Now I wanted to pass another parameter to underlying PHP script returning items. So I used "Querying For Records desc ":

"If you provide a plain object as the second argument to find, Ember Data will make a GET request with the object serialized as query params. This method returns DS.PromiseArray in the same way as find with no second argument ."

According to the documentation it should behave the same way like find with no plain object argument.

But it does not. My view is not displaying anymore.

I checked GET request. It returns exactly the same data.

I have no errors in JS.

What to do to pass parameter to PHP while getting items in a way it will work?

As you can see in this jsbin it does work. So if it doesn't work for you you either have a really old version or you're doing something else wrong.

I use this to get the model:

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return this.store.find('thing', { beer: 'heineken' });
  }
});

and that results in this request: GET /things?beer=heineken".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM