1
votes

I am currently using Ember 1.3.1 and Ember-Data. I currently use the getJSON to retrieve my data using GET from a URL. An example is shown below:

App.ProcessCreateRoute = Ember.Route.extend({

model: function() { return Ember.$.getJSON('/ProcessManager/manage? type=forms&action=list').then(function(data) { var forms = [];

  $.each(data.forms, function() {
    forms.push(this);
  });

  return forms;

I use another GET request to place data on my server by triggering a controller action in EmberJS. E.g. if I want to add a new form I do:

$.ajax({type: 'GET', url: formulateURL, dataType: 'json'});

As you can see I get the URL and just append the values in my form and send to the server.

Can anyone please tell me how I can translate this into Ember Data? I currently don't use it but how do you choose the URL to place data on the server and the URL to get data?

To place data on the server I use this URL and append data afterwards:

/ProcessManager/manage?type=processes&action=add

To get data from the server I use the URL:

/ProcessManager/manage?type=forms&action=list

Has anyone got any ideas of first steps I can do?

1

1 Answers

0
votes

You can use the DS.RESTAdapter that communicates with the server to retrieve the model. Or you could sideload the json model and add that into the model's fixtures using DS.FixtureAdapter.

For the rest adapter take a look at these links:

http://emberjs.com/api/data/classes/DS.RESTAdapter.html

http://emberjs.com/guides/models/the-rest-adapter/

http://emberjs.com/guides/models/connecting-to-an-http-server/

For the fixture adapter solution:

http://emberjs.com/api/data/classes/DS.FixtureAdapter.html

http://emberjs.com/guides/models/the-fixture-adapter/

Hope that helps