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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:33:10+00:00 2026-05-27T00:33:10+00:00

My app (singe-page layout) receives data from the server and I want a nice

  • 0

My app (singe-page layout) receives data from the server and I want a nice button based navigation like:

<a data-role="button">Button X</a>
<a data-role="button">Button Y</a>

Quite straight forward. As the user is moving back and forth in the program I’d like to reuse my div so I call $('#fancyDiv').empty() before using append() to insert new buttons – according to the program state.

OK, but now we’re running into trouble. Only at the first call buttons are displayed correctly. When I move back, pick a another menu item and refresh the page (calling empty() and append()) there are no buttons any more but plain text.

Minimizing my code it, seems like jQuery doesn’t like to append HTML anchor tags.
Below you can find some HTML code to open in your web browser. When attaching the second text you can see the link is not colored but ignored and displayed as regular text.

I also tried the html() and text() methods leading to the same result so I’d appreciate any ideas.

<html>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.js"></script>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>

    <body>
        <a data-role="button" onclick="$('#text').empty();">Empty paragraph</a>
        <a data-role="button" onclick="$('#text').append('wawon Park is a park that is located in Daegu Dalseong-gun, South Korea. The people who mainly use the park are children. It is marked to park, <a>1981 March 10.</a>')">Attach new Text</a>

        <p id="text">Hod Stuart (1879-1907) was a <a>Canadian professional</a> ice hockey cover-point (now known as a defenceman) who played nine seasons for several teams in different leagues. He also played briefly for the Ottawa Rough Riders football team</p>

        <h3>Reference Text</h3>
        <p>wawon Park is a park that is located in Daegu Dalseong-gun, South Korea. The people who mainly use the park are children. It is marked to park, <a>1981 March 10.</a></p>
    </body>
</html>

* edit/update *

OK, Rory McCrossan made a very good proposal to manually add the ui-link class to the anchor element. That technically solved my question but taking it one step further a new problem arises. I’m note sure whether to open a new question for this:

As mentioned I’d like to use buttons for the navigation and just adding ui-link class to them is not enough. I examined this fiddle with firebug and it seems some kinda initiating method is missing.
This is the code for the working button:

<a class="ui-btn ui-btn-up-c ui-btn-corner-all ui-shadow" data-role="button" data-theme="c">
<span class="ui-btn-inner ui-btn-corner-all" aria-hidden="true">
<span class="ui-btn-text">1981 March 10.</span>
</span>
</a>

and here we go for the appended button:

<a class="ui-link" data-role="button">1981 March 10.</a>

OK, quick and dirty I can just copy the code and set up all spans by my own but that sounds…. wrong and will break as soon as there’s some change in jQuery’s structure.

  • 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-27T00:33:11+00:00Added an answer on May 27, 2026 at 12:33 am

    Your code is working fine. The A tag is being appended, however it is just not being styled in any way. If you add the class ui-link to the A tag it appears the same as the others. I assume this class is being added on load by the jquery-mobile script you have included.

    See this fiddle for an example.

    Note, I’ve also moved the processing code for each button to it’s own click handler to give you much neater code.

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

Sidebar

Related Questions

I have a single page jQuery Mobile app with four data-role='pages' in place; so,
I'm developing a website. I'm using a single-page web-app style, so all of the
I've got a single Silverlight app that I'd like to display in a grid.
[Cross-posted from lib-curl mailing list] I have a single threaded app (MSVC C++ 2005)
Since the Google App Engine Datastore is based on Bigtable and we know that's
i have created a single page application of showing phonebook data in a list.
I'm used to thinking about a single-page application startup happening like this: 1. Bootstrap
Could i include a single page .cshtml in a MVC3 app (without controller)? I
I'm building a Zend-based Web app that will permit third-party extensions. Essentially, this application's
I'm working on converting a single-page app to backbone.JS. The View below uses the

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.