ember.js - My data shows on one page and not the other on Ember -


i'm using ember data build web app, , somehow data shows on 1 template , not other. ember console shows model correctly hooked route, don't know why data won't show.

the data i'm trying show {{stacktitle}} in model 'stack'.

i'm using local storage adapter provided via ember's tutorial... maybe that's problem?

here's template (the 1 that's not displaying data):

  <script type="text/x-handlebars" data-template-name="stack">     <div class="container-fluid">       <div class="row">         <a href="#"><button class="btn btn-default" type="button">back</button></a>          <button class="btn btn-default" type="submit">save</button>       </div>          <h1>           <label {{action "editstack" on="doubleclick"}}>{{stacktitle}}</label>            {{input              value=stacktitle             action="createstack"}}  {{debugger}}         <div>{{stacktitle}}</div>              </h1>            {{partial "todos"}}      </div>   </script> 

and here's router:

todos.stackroute = ember.route.extend({   model: function(params) {     return this.store.find('stack', params.stack_id);   }, }); 

my controller:

todos.stackcontroller = ember.controller.extend({      setupcontroller: function(controller, model) {         controller.set('model', model);     },      actions: {          createstack: function() {              var title = this.get('stacktitle');             if (!title.trim()) { return; }              var stack = this.store.createrecord('stack', {                 stacktitle: title,             });              stack.save().then(function() {                 var promises = ember.a();                 stack.get('todos').foreach(function(todo) {                     promises.push(todo.save());                 });                 ember.rsvp.promise.all(promises).then(function(resolvedpromises){                     alert('all saved!');                 })             });              console.log(this.store.all('stack'));     }, } }); 

my model:

todos.stack = ds.model.extend({     stacktitle: ds.attr('string'),     todos: ds.hasmany('todo', {async: true} ),     istaken: ds.attr('boolean'), }); 

i'd love if point me in right direction. thank you!

setupcontroller isn't needed (it's doing exact same job model hook in route, after model hook done it's work. delete it.

as issue, don't think ember.controller proxies model properties. you'd need use ember.objectcontroller that, seeing ember.objectcontroller on tom dale's hit list (it's going away eventually), should access stacktitle in templates model.stacktitle.


Popular posts from this blog