Here I have the flow ...
First of all, jquery posts new comment on the server:
$ Post (this.action, $ (this). Serialize (), blank, 'script');
Then in comment controller:
def make @comment = lots of stuff going here but this works ... if @ comment .save flash [: notice] = "Successfully commented." Response_to do | Format | Format.js end end
OK and this is where I got stuck, then create.js.erb:
$ (" Cmtbox "). Html ("& lt;% = escape_javascript (render: partial = & gt;" comments / comment ")%>);
and partial:
& lt; Div class = "cmtbox" id = "comment_ & gt; & Gt; & Lt;% = comment.content% & gt; & Lt; / Div & gt;
Where I am stuck, I am making a partial call to create.js.erb ... how will I pass, which needs partial populations? I get an error now: "Id has been called for zero, which can be accidentally 4 - If you want to actually identify the zero, then use the object_id
thanks!
You should use:
render: partial = & gt; @ comment
or
render: partial = & gt; "comments / comment" ,: object = & gt; @ comment
or
render: partial = & gt; "comments / comment" ,: Local = & gt; {: Comment = & gt; @ Comment}
Comments
Post a Comment