ember.js can't get pagination from metadata -


i example this,but still can't pagination

this store.js.coffee

eme.serializer = ds.restserializer.create()  eme.serializer.configure   meta: 'meta'   pagination: 'pagination'  eme.customadapter = ds.restadapter.extend   serializer: eme.serializer   namespace: "api/v1"  eme.store = ds.store.extend   revision: 13   adapter: 'eme.customadapter' 

this controller

eme.pluginscontroller = em.arraycontroller.extend   content: []   pagination: (->      if this.get('model.isloaded')       console.log @get('model.type')       console.log @get('store').typemapfor(modeltype).metadata        modeltype = @get('model.type')       @get('store').typemapfor(modeltype).metadata.pagination   ).property('model.isloaded') 

this response

{   "meta":{     "pagination":{       "total_count":16,       "total_pages":2,       "current_page":1     }   },   "plugins":[{     "id":"1",     "name":"zhangsan",   }] } 

this log:

eme.plugin

object {}

in example pasted, modeltype variable output console before has been defined. why not seeing pagination data expected.

i've created jsbin modified version of code , appears output pagination data correctly. see: http://jsbin.com/anikafo/2/edit

app = ember.application.create({});  app.indexroute = ember.route.extend({   model: function(){     return app.plugin.find();   } });  app.indexcontroller = ember.arraycontroller.extend({   pagination: function() {     if (this.get('model.isloaded')) {       var store = this.get('store');       modeltype = this.get('model.type');       console.log('modeltype: ', this.get('model.type'));       var metadata = store.typemapfor(modeltype).metadata;       console.log('metadata: ', metadata);       return metadata.pagination;     }   }.property('model.isloaded') });   app.store = ds.store.extend({   adapter: 'app.adapter' });  app.plugin = ds.model.extend({   name: ds.attr('string') });  app.serializer = ds.restserializer.create();  app.serializer.configure({   meta: 'meta',   pagination: 'pagination' });  app.adapter = ds.restadapter.extend({   serializer: app.serializer,   ajax: function(url, type, hash) {     console.log('app.adapter.ajax:', url, type, hash);     json = app.restdata[url];     if (json) {       console.log('app.adapter.ajax: found restdata: ', json);       return new ember.rsvp.promise(function(resolve, reject) {         ember.run(null, resolve, json);       });     } else {       console.log('app.adapter.ajax: no restdata url, calling api', url);       return this._super(url, type, hash);     }   } });  app.restdata = { '/plugins':   {     "meta":{     "pagination":{       "total_count":16,       "total_pages":2,       "current_page":1     }     },     "plugins":[{     "id":"1",     "name":"zhangsan"     }]   } }; 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

visual studio - TFS will not accept changes I've made to a Java project -