Trying to use Ember and Ember-Data for an Ember app which is embedded in an existing site at URL:
(my-site)/patients
I have a REST/JSON endpoint at:
(my-site)/smart/patients
which returns json as directed by the Ember guide:
{"patients":[{"id":1,"user_id":6,....] }
My js looks like this:
App = Ember.Application.create({
rootElement: '#patient-data',
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: true,
LOG_ACTIVE_GENERATION: true
});
App.Router.map(function() {
this.resource('patients');
});
App.PatientsRoute = Ember.Route.extend({
model: function() {
return this.store.find('patient');
}
});
App.Store = DS.Store.extend({
url: 'http://(my-site)/smart'
});
App.Patient = DS.Model.extend({
userId: DS.attr('number'),
etc...
});
App.PatientView = Ember.View.extend({
didInsertElement: function() {
do stuff...
});
}
});
I am able to get this working by using (with root element [patients] removed from JSON response):
App.PatientsRoute = Ember.Route.extend({
model: function() {
return Ember.$.getJSON('http:(my-site)/smart/patients');
}
});
But, I can't get the RESTAdapter to do anything in the PatientsRoute...
I feel like I've tried every permutation of rootURL (App.Router), url (DS.Store) etc and can't get this to function...what am I missing?
Aucun commentaire:
Enregistrer un commentaire