ember.js - Ember-Data: Adding Server Queries to AJAX Requests -


I am having problems in a specific case using amber-data.

Usually follow Amber a model class, route, ajax request, and return JSON, a similar pattern.

The RESTAdapter tries to automatically create a URL to send to the server, which is fine for some situations, but I need full control over some of my request URLs, especially when adding additional parameters Or an API comes to match a path that has a completely different URL structure.

Sadly, Amber, there is no guide for it, I got to know something about

I know what happens under the hood, but I have some To correct the use cases, do not want to break amber data. API / Rest

  • Models and resources that I want to populate are View-debtors
  • access to specific services For debtor / list
  • I get page numbering = 10 & amp; Page_number = 1 must pass an additional parameter, for example.

    I am completely lost how to do it. I can not change the API structure ... there are many services based on them.


    Some small progress

    I went ahead and used

  • I have used the RESTAdapter Has increased. "List" to change name space to "API / Rest / Debt"
  • I changed model hook for "view-debtor" route for store.find ('list') < / Code>

    The result is that the AJAX call is almost correct ... I just need to add that extra parameter to the server query.

    This is where I stand now ... Can I add those server questions through model hook? Or better yet can I also control the server query through ember functions to get a new AJAX request?

    A little step back? Is my method so far a good practice? Because I'm using the model hook of the root, to set the model in the list, will it only work if the URL is typed directly?

    Many questions: p

    Using a given object at the end of the request will add a query string.

      // will generate this / API / rest / debtor / list? Page_ Size = 1 and page_number = 10 this.store.find ('list', {page_size: 1, page_number: 10});   

    Personally, I think that to defame this model name and name space, this is a little hack to fit your backend's URL structure. It really depends on you what you are trying to do. If you want all the complete features of CRUD using Amber-data for this particular list of data, then you are going to endpoint the end-point left and right. Whether or not the amber data really helps you question or if you are just reading the data, then I will get the data using jquery completely and take it into amber data.

      var store = this.store; $ .getJSON ('/ api / rest / debtor / lists? Page_size = 1 & amp; page_number = 10'). Then (pay for function (jsn) {// fix] http://emberjs.com/api/data/ class / DS.Store.html # method_pushPayload store.pushPayload ('type', json);} if necessary . (Function () {return store.all ('type'); // or store.filter ('type') if you have been returned to model hook, then want to filter});   



  • Comments

    Popular posts from this blog

    ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

    Matlab transpose a table vector -

    c# - Textbox not clickable but editable -