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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:17:07+00:00 2026-06-16T00:17:07+00:00

I can create a 2 item nav bar in a jQuery mobile page with

  • 0

I can create a 2 item nav bar in a jQuery mobile page with the following code snippet:

<div id="nav-bar" data-role="navbar">
    <ul id="nav-list">
        <li><a id="link1" href="#">Nav 1</a></li>
        <li><a id="link2" href="#">Nav 2</a></li>
    </ul>
</div>

I am attempting to programatically add a third nav bar element using various versions of the following code:

$("#nav-list").append("<li><a id='newElement' href='link3'>Nav 3</a></li>");
$("#nav-bar").navbar();
//$("#pageName").page();
//$("#pageName").trigger("create");
//$("#nav-list").listview("refresh");

When I execute this I see the “Nav 3” link appear but it does not take on the jQuery mobile formatting of the other links.

Any help would be greatly appreciated.

  • 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-16T00:17:08+00:00Added an answer on June 16, 2026 at 12:17 am

    I had lost my mind because of this problem. .navbar() used to work in previous versions, for some reason not any more.

    I have made a function whose job is to add a new element and then rebuild navbar. One part of it is taken from someone else so I cant take full responsibility for this code (mathod used for style stripping).

    Here’s working example: http://jsfiddle.net/Gajotres/V6nHp/

    And here’s a method used:

    var navbarHandler = {
        addNewNavBarElement:function(navBarID, newElementID, newElementText) {
            var navbar = $("#" + navBarID);
    
            var li = $("<li></li>");        
            var a  = $("<a></a>");
            a.attr("id", newElementID).text(newElementText);
            li.append(a);
    
            navbar = navbarHandler.clearNavBarStyle(navbar);
    
            navbar.navbar("destroy");
            li.appendTo($("#" + navBarID + " ul"));
            navbar.navbar();
        },
        clearNavBarStyle:function(navbar){
            navbar.find("*").andSelf().each(function(){
                $(this).removeClass(function(i, cn){
                    var matches = cn.match (/ui-[\w\-]+/g) || [];
                    return (matches.join (' '));
                });
                if ($(this).attr("class") == "") {
                    $(this).removeAttr("class");
                }
            });
            return navbar;   
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a Django model that handles the following: An Item can
I have the following situation: <nav id=access role=navigation> <div class=menu> <ul> <li class=page_item><a href=#pricing
Here's the idea: User hits a page where he can create an item. On
How can i create a chain of viewcontrollers and push them into navigation item
In an iPhone app, the User can create Items - each Item needs to
I am trying to create custom function for Main Nav menu where I can
I know that I can create two different borders for my item groups and
I'm trying to find out how I can create a pop-up menu bar, after
I'm trying to create this nav menu (green highlight is the active page, gray
Does anyone have a walk through/example/blog of how I can dynamically create the item

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.