ember.js - Ember Array Controller - function not loading -


i new ember , trying load small array controller. trouble is, addcard function i've defined in cardscontroller not showing , getting error: "object function() has no method 'addcard'". doing wrong? using following:

handlebars-1.0.0-rc.3.js,
ember-1.0.0-rc.3.js,
ember-data.js

here code:

app = ember.application.create({     ready: function(){         //populate content[] in cardcontroller         app.getcards();     } });  app.getcards = function(){     card1 = app.card.create({                 id: 0,                 title: 'alabama',                 desc: 'montgomery'             });      app.cardscontroller.addcard(card1); };  app.card = ember.object.extend({     id: null,     title: null,     desc: null,     current: true });  app.cardscontroller = ember.arraycontroller.extend({     content: [],      //property adds item content     addcard: function(item){         this.addobject(item);     } }); 

assuming is code make app, need define controller object direct after application create statement, , before use it, in order:

app = ember.application.create({   ready: function(){     //populate content[] in cardcontroller     app.getcards();   } });  app.card = ember.object.extend({   id: null,   title: null,   desc: null,   current: true });  app.cardscontroller = ember.arraycontroller.create({   content: [],    //property adds item content   addcard: function(item){     this.addobject(item);   } });  app.getcards = function(){   card1 = app.card.create({             id: 0,             title: 'alabama',             desc: 'montgomery'         });    app.cardscontroller.addcard(card1); }; 

working fiddle proof.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -