Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:01:10+00:00 2026-06-07T04:01:10+00:00

TL; DR: How can I use the same layout multiple times on a page?

  • 0

TL; DR: How can I use the same layout multiple times on a page? All attempts to render partials with recurring layouts go into the elements where the first time the layout is used.

Quick Info:

Using

Rails 2.3.14
Ruby 1.8.7      

My partials use content_for, which is pretty handy with layouts.

Basically, my layout looks like this:

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

Generally, this is how I use my modal layout:

<% content_for :modal_header do %>
    header text / elements
<% end %>

<% content_for :modal_body do %>
    body info / settings for object or warning message, etc
<% end %>

This is how I render modals on my page:

<%= render :partial => "section_options", :layout => "modal" %>

and that works really well

BUT

when, on the same page, I try to render another modal:

<%= render :partial => "section_content_options", :layout => "modal" %>

This is what happens to the modal at the top of my page (occurs first in the HTML document)

<div class="header">
    -- header from second partial --
    -- header from first partial --
</div>
<div class="body">
    -- body from second partial --
    -- body from first partial --
</div>

and then later in the page, where the content from the second partial is supposed to be:
everything is rendered correctly …
For the sake of this example:

<div class="header">
    section content options
</div>

<div class="body">
   section contents options ... options
   lil confirm / cancel buttons
</div>

Is there a way to fix this? This behavior really messes with javascript bindings as well. so. yup.

Is there a bug with layouts in rails 2.3.14? do I have to upgrade to rails 3 to get rid of this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:01:11+00:00Added an answer on June 7, 2026 at 4:01 am

    Modals should be rendered using partials, not layouts. Layouts are designed as a way of defining the overall layout of the entire site, not specific parts. Something like a modal (which by design is specific) should be a partial that’s rendered either through a condition or JavaScript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined CSS in MasterPage so that all pages can use the same
how can I use the same UI template (*.ui.xml file) with multiple Java objects
Can the application use set same char in the XON and XOFF? If yes,
I can use HttpListener to listen for requests coming from the same computer, but
Can I use the WPF DataGrid control in the same way I use a
can i use fragments and map view in the same activity. I have seen
how can i use jQuery to show/hide the same div area... essentially swapping out
How can I use contains and iexact Field lookups at the same query in
Possible Duplicate: How can I use a string with the same name of an
How can I use Process.Start(), but have the launched process not in the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.