This would be easy to do with regular JS/AJAX, but I am trying to learn and do this the Ember way (v2.6):
I have a URL /dates
and on this page there are two calendars. On page load, a request is made to the server to get which date to pre-select in calendar 1. The response looks good, but the date is not appearing in the template.
/templates/dates.hbs:
Preselect: [] //this is outputting: Preselect: []
/routes/dates.js:
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return this.get('store').findAll('my-date').get('firstObject');
}
});
/models/my-date.js:
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
export default Model.extend({
preselect: attr()
});
Server response:
{"myDates":{"id":1,"preselect":"2016-10-02"}}
There will be more requests for calendar 2 later, but I'm stuck on calendar 1.
Why is the model data not appearing on the page? There are no errors in ember inspector. The model does appear in ember inspector with the proper data.
Thank you.
Aucun commentaire:
Enregistrer un commentaire