NullVoxPopuli
NullVoxPopuli

Reputation: 65183

Render a partial via page.replace_html and using a layout?

here is what I'm trying to do:

    page.replace_html('manage_categories_list', :partial => "/categories/categories", :layout => :modal)

But, I get this error on the above code:

NoMethodError (undefined method `include?' for :modal:Symbol):

What I want to be able to do, is have template HTML for a modal dialog window. And set the header (h2) and the body (div) of that modal with any partial. =\

modal.html.erb:

<div class="fixed_modal">
    <div class="modal_header">
        <%= yield :header %>
    </div>
    <div class="modal_body">
        <%= yield %>
    </div>
</div>

The partial I'm trying to render:

<% content_for :header do %>
    Manage Categories
<% end %>

.... rest doesn't matter as it just goes into the yield

I'm using rail 2.3.14

Upvotes: 0

Views: 1972

Answers (2)

tihm
tihm

Reputation: 620

Most likely, you need to change it to ..., :layout => 'modal':

page.replace_html('manage_categories_list', :partial => "/categories/categories", :layout => :modal)

The #replace_html method accepts options like #render. For the :layout option, you either need to pass true, or a string layout file name (See the docs for #render).

The layout argument will be the 'xyz' part of the filename in app/views/layouts/xyz.html.erb.

Upvotes: 1

RadBrad
RadBrad

Reputation: 7304

The argument to :layout can't be a symbol try

:layout=>'modal'

This assumes you have a layout in app/views/layouts/modal.html.erb

Upvotes: 1

Related Questions