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 8095099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:00:50+00:00 2026-06-05T21:00:50+00:00

So I have a user profile with a tab navigation in it: <div id=proftab>

  • 0

So I have a user profile with a tab navigation in it:

<div id="proftab">
    <ul class="nav nav-tabs">
          <li class="active">
            <%= link_to "About", about_users_path, :remote => true, :data => {:toggle=>"tab"} %>
          </li>
          <li><%= link_to "Pictures", pictures_users_path, :remote => true, :data => {:toggle=>"tab"} %></li>
    </ul>
</div>
<div class="row">
    <div id="profile" class="span9">

    </div>
</div>

I’ve managed to let Ajax render certain partials.
Now, when I click on the tabs the partials load in my target placeholder div. But my problem is that the tab list items don’t change their active class depending on which partial was rendered. Don’t really have an idea how to fix this.

I think it has something to do with the link or ids. When I build the tab like in the bootstrap documentation (with divs that are hidden and shown) it works perfectly. But I think it somehow can’t handle the partials right. I hope someone can help me!
Thx!

routes.rb

get "users/about" => 'users#about', :as => :about_users

get "users/pictures" => 'users#pictures', :as => :pictures_users

users_controller.rb

class UsersController < ApplicationController
  before_filter :authenticate_user!

  def index
    @users = User.all
  end

  def show
    @user = User.find(params[:id])
  end

  def about
    respond_to do |format|
      format.js
    end
  end

  def pictures
    respond_to do |format|
      format.js
    end
  end
end

views/users/about.js.erb

$("#profile").html("<%= escape_javascript(render(:partial => 'about')) %>");

views/users/pictures.js.erb

$("#profile").html("<%= escape_javascript(render(:partial => 'pictures')) %>");

views/users/_about.html.erb

<div class="tab-pane active" id="#about">
     about
</div> 

views/users/_pictures.html.erb

<div class="tab-pane active" id="#pictures">
     pictures
</div> 

tabs.js

$('#proftab a').click(function (e) {
    e.preventDefault();
    $(this).tab('show');
})
  • 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-05T21:00:51+00:00Added an answer on June 5, 2026 at 9:00 pm

    You actually don’t need the bootstrap javascript for tabs at all. I removed the data-toggle from the links and changed my javascript to this:

    $('#proftab a').click(function (e) {
        $('ul.nav-tabs li.active').removeClass('active')
        $(this).parent('li').addClass('active')
    })
    

    worked perfectly!

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

Sidebar

Related Questions

I have code that looks like this: <div id="header"> <ul class="tabs"> <li><a href="/user/view"><span class="tab">Profile</span></a></li>
I have a user and nested profile class as follows: class User < ActiveRecord::Base
Dear all, I have a question about Facebook Page: ( NOT user profile page,
I have two models: User (email:string) Profile (name:string) class User < ActiveRecord::Base has_one :profile
I have user profile model with M2M field class Account(models.Model): ... friends = models.ManyToManyField('self',
I have a User & Profile Models. A user has_one profile IE. class User
I have a Facebook application that has a user profile tab. The specs of
I have 2 Models: # user.rb class User < ActiveRecord::Base has_one :profile, :dependent =>
I have a user profile page on my web app which has contact information.
I have the following models: User: hasOne Profile, Page hasMany Comment Comment: belongsTo User,

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.