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

  • SEARCH
  • Home
  • 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 8337159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:12:58+00:00 2026-06-09T04:12:58+00:00

So I have a rails application that has two different navigation headers. One that

  • 0

So I have a rails application that has two different navigation headers. One that is used for the majority of pages and another navigation header that is used for only a few pages. Additionally since the navigation is loaded in the application.html.erb page (shared between all the pages of the application) the navigation html is never refreshed from the server unless the user refreshes the page. And since each page is loaded through ajax (using pjax) it means that when I move between two pages that need different navigation headers the navigation header is not updated.

I have a few solutions that are possible but I don’t like them since I don’t want to have to add code to every view that I have. The main solution being move the navigation header into the views (instead of the global application.html.erb), or add javascript to every page that checks that the navigation is the correct one and if not replace it. But for replacing it I’m not sure how to load the html which is a partial and contains data from the models.

Note: directly visiting each url works fine.

I feel like I’m missing some easy approach since this feels like it should be a fairly common problem but I am unable to find anything while searching.

Edit: and I am using jquery

  • 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-09T04:13:00+00:00Added an answer on June 9, 2026 at 4:13 am

    Since you have only two navs, generate them both in your layout and hide them.

    <div id="nav">
      <div id="nav1" class="nav" style="display: none"><a href="#">Nav1</a></div>
      <div id="nav2" class="nav" style="display: none"><a href="#">Nav2</a></div>
    </div>
    

    In your page’s JS, create a function that will show the one you want. When you update the page via pjax, you’ll want to pass in some JS to execute, calling chooseNav with the one you want.

    <script type="text/javascript">
      function chooseNav(sel) {
        $('#nav .nav').hide();
        $('#nav' + sel).show();
      }
    
      $(function() {
        chooseNav(1);  // Default nav to load when page loads
      });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails application that has three different types of users and I
I have a Ruby on Rails application that has two active environments, Stage and
I have a rails app that has two models one is vender and the
I have a Rails simple application that has two main models. A person model
I have a Rails 3 application that needs to display images from another application.
I'm developing a Rails 3 application that has two user types: Teacher and Company.
I'm developing a Rails 3 application that has two user types: Teacher and Company.
I have two different Rails application speaking with each other through API calls. Gone
I have a Rails application that unfortunately after a request to a controller, has
My rails application has two models, gallery and photo. Galleries have many photos and

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.