Note that there are some explanatory texts on larger screens.

plurals
  1. POemberjs and ember-data -creating record via form submission returns undefined
    text
    copied!<p>I have this <strong><a href="http://jsfiddle.net/mzseQ/5/" rel="nofollow">jsfiddle</a></strong>. Everything works excepting that i can't create a new comment by submitting the comment's form. when i <strong>submit a form the console shows undefined</strong>. What I hope to achive is to grab an existing post and then create a comment that belongs to that post. So this the flow of things, a user will click on <strong>post</strong> then click a specific <strong>post title</strong> to display it and then click on <strong>add comment</strong> to comment on that post. It is important to note that at the moment, clicking on <strong>add comment button</strong> will return <strong>undefined</strong>. </p> <p><em>Relevant section of the code with the <strong>addComment</strong> and <strong>save</strong> methods.</em></p> <pre><code>EmBlog.CommentNewController = Em.ObjectController.extend({ needs: ['postsShow'], isAddingNew: false, addComment: function(body){ post = this.get('controllers.postsShow.model'); store = post.get('transaction'); store.createRecord(EmBlog.Comment, {body: body}); this.set('isAddingNew', true); }, save: function(){ console.log(this.store.commit()); } }); </code></pre> <p>**The relevant section from the handlebars template</p> <pre><code>&lt;script type='text/x-handlebars' data-template-name='comment/new'&gt; {{#if controller.isAddingNew}} &lt;form {{action save on='submit'}}&gt; {{view Ember.TextArea valueBinding="body" placeholder="body"}} &lt;button type="submit"&gt; save comment &lt;/button&gt; &lt;/form&gt; {{/if}} &lt;br/&gt; &lt;div&gt; &lt;button {{action addComment}} {{bindAttr disabled="isAddingNew"}}&gt; Add Comment &lt;/button&gt; &lt;/div&gt; &lt;/script&gt; </code></pre> <p><strong>The comment form is submitted via 'posts/show template' using render</strong></p> <pre><code> &lt;script type="text/x-handlebars" data-template-name="posts/show"&gt; &lt;p&gt; Comments&lt;/p&gt; {{render 'comment/new' comments}} &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload