I am creating a webf in which there is a UI split in two sides, menu bar and content area. The menu bar contains a list of all the blogs titles that a user has written. When a title is clicked, the content area should be changed to show the post of that blog.
1.) So in my menu bar, I have:
& lt; % = Link_to blog.title, blog ,: Remote = & gt; Correct% & gt; And in my content area, I have:
& lt; Div id = "contenthere" & gt; & Lt; / Div & gt; 2.) So, in my opinion, this should trigger the blog controller's show method. There, I have the following in the law:
@blog = Blog.find (params [: id]) response_to do format | Format.js {render: show_blog} end 3.) In the View / Blog folder, go to see the file named show_blog.js.erb:
$ ("# Contenthere") Html ("& lt;% = escape_javascript (render: partial = & gt;" show_blog ")%>"); which will take my div to commenthere ID and _bow_blog.html. ARB will present partial (located in the blog view folder) with the blog parameter equal to the blog parameter in which my blog administrator was set.
4.) So my show blog is partly this code:
<% = @ blog.title% & gt; & Lt;% = @ blog.user_id% & gt; Edit: Actually, I search and find out that I can not use the 'render' method from within the asset folder - where can I call jserb? I moved it to the blog view folder, the home view folder (index.html.erb), and the bus / view / folder ... the error has ended, but the link is not working ... EDIT: Keep show_blog.js.erb in my thoughts / blogs folder, as this blog controller is calling it. Nothing is going on when clicking on the links shown in the console and any JS errors. Is JS being called?
EDIT: My last answer has been changed to reflect.
@blog = blog.find (params [: id]) response_to do | Format | Format.js {render: show_blog} end This is not the railway's default argument.
You have not provided, how do you say the way,
def show_blog @blog = Blog.find (params [: id]) response_to do format | Format.js End Search Then search for ideas / blog in Rail show_blog.js.erb and submit that file will do. In addition to this, you need to pass partially to the actual example, because the only part of the code of the petals is and do not know, what is @blog:
$ ("#contenthere"). Attachment ("& lt;% = j render: partial = & gt;" show_blog ",: local = & gt; {: @ blog = & gt; @blog}%>;);
No comments:
Post a Comment