Rendering w/ JS element in a li
I'm working to include in my rails application some prototype to display pages associated with a site. Without JS it works properly, but when I tell the page to update through a RJS with something like -
page.insert_html :bottom, 'page_listing', :partial => 'page'
I have a partial page -
<li><%=开发者_StackOverflow中文版 page.url %> - <em><%= page.status %></em></li>
in my show view I also have -
<ul id="page_listing">
<% @site.pages.each do |page| %>
<%= render :partial => 'page', :locals => {:page => page} %>
<% end %>
</ul>
So with just ERB its fine, but with rjs, I get -
ActionView::Template::Error (can't convert ActionView::Helpers::JavaScriptProxy to String (ActionView::Helpers::JavaScriptProxy#to_str gives ActionView::Helpers::JavaScriptProxy)):
So basically I think its not able to place into the li the paramaters. (If I refresh the page it does show the correct text) But I'm not sure where to go to find this answer, Thanks!
I think I figured it out.
It looks like in my partial I have to include the whole loop.
<% @site.pages.each do |page| %>
<li> .....</li>
<% end %>
I guess live and learn
精彩评论