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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:18:36+00:00 2026-05-23T00:18:36+00:00

I am trying to use the tabs function from jQuery UI in a Rails

  • 0

I am trying to use the tabs function from jQuery UI in a Rails app. I am using a helper for the navigation and I would like to keep it that way. The code in my helper is:

def links_for_navigation
  html = ""
  html  = <<HTML
   <ul>
     <li><a href="#tabs-1">Courses</a></li>
     <li><a href="#tabs-2">Parts</a></li>
     <li><a href="#tabs-3">Categories</a></li>
   </ul>    
  <div id="tabs-1"><% link_to "Courses", courses_path %>
  <div id="tabs-2"><% link_to "Parts", parts_path %>
  <div id="tabs-3"><% link_to "Categories", categories_path %>
  HTML
end

My view pulls in the code with <% links_for_navigation %>

I added to my application.js:

jQuery(function() {
 jQuery("#tabs").tabs();
});

And my application.html.erb has:

<%= stylesheet_link_tag 'courses', 'jquery-ui-1.8.13.custom.css' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag 'jquery-1.5.1.min.js', 'jquery-ui-1.8.13.custom.min.js', 'application' %>

When I try to load the page I get cannot find string HTML before EOF. What am I doing wrong?

  • 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-05-23T00:18:36+00:00Added an answer on May 23, 2026 at 12:18 am

    I recommend using a partial, rather than a helper method. The partial, I’ll call it _nav.html.erb, would look like the following (note the id="tabs" on the surrounding div):

    <div id="tabs">
        <ul>
            <li>
                <a href="#tabs-1">Courses</a>
            </li>
            <li>
                <a href="#tabs-2">Parts</a>
            </li>
            <li>
                <a href="#tabs-3">Categories</a>
            </li>
        </ul>
    
        <div id="tabs-1">
            <%= link_to "Courses", courses_path %>
        </div>
        <div id="tabs-2">
            <%= link_to "Parts", parts_path %>
        </div>
        <div id="tabs-3">
            <%= link_to "Categories", categories_path %>
        </div>
    </div>
    

    Then in the appropriate view file, you can insert the partial with a call to render:

    <%= render :partial => 'nav' %>
    

    I’ve never used jQuery tabs but try adding this to application.js, based on this example. The "#tabs" selector inside $() corresponds to the id="tabs" from above:

    $(function() {
        $( "#tabs" ).tabs();
    });
    

    I’ll offer a couple tips/reminders as well:

    • Embedded ruby (ERB) tags needs to have an = if you want them to print something, i.e. <%= @user.name %> versus <% @user.name %>. The first will output a string into the file, the second will not. There are cases where you might not want to print something, so you would leave off the =.
    • Be sure to close all your HTML tags. Rails’ ERB files can get messy anyways, so proper HTML structure is key.
    • Avoid using HTML outside of *.html.erb files. This isn’t a golden rule, but it’s a good rule of thumb.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jQuery UI tabs much like a Master Page in ASP.Net.
I am trying to use this section of code from jQuery UI's tabs example
I'm trying to use jquery-ui tabs with my rails application. The tabs are visible
I'm trying to use jquery tabs, i got the code from the site: http://docs.jquery.com/UI/Tabs
I am trying to make a jquery similar tabs. since its for single use
I'm trying to use this with tabs that load content with ajax into a
I'm trying to use the JQuery tools tooltips plugin in a site that I'm
Actually I am trying to do jquery tabs. I have written a code that
I am trying to use jQuery(#element-id).parent().addClass('some-class'); I have a structure something like this: <div
I'm trying to use the JQuery UI tabs by pointing one of the tabs

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.