SO,
I am working on an Ember app and experiencing a confusing problem. At the index route the app performs a find() and returns an array of
datasetand links to a template to show further details about each
datasetwhich are sideloaded when a resquest is made to find by id. (i.e. find(1), where 1 is the id.)
The first request with an id works fine, returning the dataset object and it's sideloaded data, however subsequent requests do not seem to do anything. The server does not see any request if I try to navigate to any other dataset after the first one's details have been loaded. However if I navigate from a specific dataset back to index and then back to any dataset it will send the request again (twice even, am not sure if this a related problem) and work. In other words:
/# works
/#/1 also works (or any other id as long as it is the first one visited)
/#/1 then /#/2 does not work, no request is sent
/#/1 followed by /# then /#/2 does work, maintaining the data at /#/1 & getting the new data for /#/2.
How do I get all of the specific dataset objects to return upon visiting them, without the hacky pitstop at index? Any advice would be greatly appreciated, thank you in advance!
The code:
-app.js
/************************** * Application **************************/ var App = Em.Application.create(); App.Router.map(function() { this.resource('application', {path:'/'}, function() { this.resource('dataset', {path: '/:dataset_id'}, function() { }); }); }); App.ApplicationRoute = Em.Route.extend({ model: function() { return App.Dataset.find(); } }); App.DatasetRoute = Em.Route.extend({ activate: function() { this.modelFor('dataset').reload(); } }); /************************** * Models **************************/ App.Store = DS.Store.extend({ adapter: DS.RESTAdapter.create({ url: 'http://***.***.***.***:5000', namespace: 'api', serializer: DS.RESTSerializer.extend({ primaryKey: function(type) { return '_id'; } }) }) }); App.Dataset = DS.Model.extend({ dataset: DS.attr('string'), title: DS.attr('string'), points: DS.hasMany('App.Point') }); App.Point = DS.Model.extend({ dataset: DS.attr('string'), dataset_id: DS.attr('string'), date: DS.attr('date'), value: DS.attr('string') });