javascript - Accessing child functions/properties with arranged content in Ember.js -


i'm having trouble figuring out do. have 'post' controller has function 'imageurl'. function takes string (ex image_1.jpg), , prepends root path (ex images/image_1.png). problem i'm having in parent controller, want display 4 recent posts. problem cant use "imageurl" on arranged content. here relevant code.

app.homecontroller = ember.arraycontroller.extend({     itemcontroller: 'post',     sortproperties: ['date'],     sortascending: false,      topposts: function(){         var content = this.get('arrangedcontent');         if(content.length >= 4) content = content.splice(0, 3);         return content;     }.property('content') });  app.postcontroller = ember.controller.extend({     title: ember.computed.alias('model.title'),     body: ember.computed.alias('model.body'),     postdate: ember.computed.alias('model.postdate'),     imagename: ember.computed.alias('model.imagename'),      imageurl: function(){         var id = this.get('model.id');         var postimageroot = "images/posts/" + id + "/";         var imagename = this.get('model.imagename');         return postimageroot + imagename;      }.property('imagename') });   app.post = ds.model.extend({     authorid:   ds.attr('number'),     author:     ds.belongsto('author'),     title:      ds.attr('string'),     body:       ds.attr('string'),     snippet:    ds.attr('string'),     postdate:   ds.attr('date'),     imagename:  ds.attr('string') }); 

any appreciated! :d , have searched while , haven't found this. using array proxy help? or there simple i'm missing?

i move imageurl property model:

app.post = ds.model.extend({     ...     imagename:  ds.attr('string'),      imageurl: ember.computed('id', 'imagename', function() {       var id = this.get('id');       var postimageroot = "images/posts/" + id + "/";       var imagename = this.get('imagename');       return postimageroot + imagename;     }) }); 

http://emberjs.jsbin.com/nohazilegi/1/


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -