lundi 26 janvier 2015

ember meta information seems to be shared by controllers

meta information. index and limit is used within link-tos for pagination.


the meta information seems to be shared amongst controllers. the router is as such



this.resource('persons', { path: 'persons/index/:index/limit/:limit' }, function() {
this.resource('personaddresess', { path: 'personaddresess/:person_id/index/:index/limit/:limit' });
});


the toplevel navigation have link-tos with index of 0 and limit of 50



{{#link-to 'persons' 0 50 }}


the url is correct at #/persons/index/0/limit/50


the secondlevel navigation for addresses use index of 0 and limit of 9



{{#link-to 'personaddresses' id 0 9}}


after 'clicking' on the above link-to the limit for BOTH persons and personaddresses is set to 9.


ie. the url is now #/persons/index/0/limit/9/person/1/personaddresses/1/index/0/limit/9


Both routes use the following for obtaining models from REST



model: function(params) {
var index = numeral().unformat(params.index);
var limit = numeral().unformat(params.limit);
return this.store.find(yaddayadda);


now it seems that the meta is shared amongst controllers. should each controller not have their own meta (since each have their own model)?



App.PersonsController = Ember.ObjectController.extend({
meta: function() {
return this.get('model.meta');
}.property('model.meta'),
});

App.PersonAddressController = Ember.ObjectController.extend({
meta: function() {
return this.get('model.meta');
}.property('model.meta'),
});


The meta does pass thru a extractMeta function after each find that sets the meta for each type on the store.



store.setMetadataFor(type, { limit: payload.limit }); // sets the metadata for "post"


However, neither the model type are the same (one is Person, the other is PersonAddress); moreover, the store parameters are not used. The hardcoded params (0,50 and 0,9) passed in link-to are used?!





Aucun commentaire:

Enregistrer un commentaire