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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:57:32+00:00 2026-06-09T16:57:32+00:00

Is there a way to make jQuery Mobile render a javascript-generated link as a

  • 0

Is there a way to make jQuery Mobile render a javascript-generated link as a button widget, like it does automatically when loading the page?

I have javascript like this to create the link dynamically:

var ws=document.getElementById('workspace'); // empty <div id="workspace"></div>
ws.innerHTML='<a id="myb" href="foo.php" data-role="button">baz</a>';

And of course it only generates a normal link instead of a button, so my question is how do I make jQueryMobile create the button dynamically, as it would have done if the same <a id="myb" href="foo.php" data-role="button">baz</a> had appeared in the page from the beginning?

EDIT :

A script like this:

$('#tagspace').html('<a id="myb" data-inline="true" data-ajax="false"
                    href="boo.php" data-role="button">baz</a>')
              .button()
              .click(function() { window.location.href=this.href;});

Is an improvement. It does result in a button (full page width), and that is sensitive to clicks outside of the text of the label. However, this doesn’t seem to be mapped to the element containing the intended link “destination”.

The DOM results of this:

<div aria-disabled="false" class="ui-btn ui-shadow ui-btn-corner-all ui-fullsize
                                      ui-btn-block ui-btn-up-c" data-mini="false" data-inline="false" data-theme="c" data-iconpos="" data-icon="" data-wrapperels="span" data-iconshadow="true" data-shadow="true" data-corners="true"> <span class="ui-btn-inner ui-btn-corner-all">
        <span class="ui-btn-text">baz</span>
</span>
    <div aria-disabled="false" class="ui-btn-hidden" id="tagspace"> <a id="myb" data-inline="true" data-ajax="false" href="boo.php" data-role="button">baz</a>

    </div>
</div>

So, it is still not the same kind of button.

  • 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-09T16:57:33+00:00Added an answer on June 9, 2026 at 4:57 pm

    You can create a button widget by wrapping your element in a jQuery object and calling the button() method.

    $("#workspace").html("<a id='myb' href='foo.php' data-role='button'>baz</a>")
                   .button();
    

    Update: The button widget prevents the default behavior of the link, so you will have to add a click handler if you want that behavior back:

    $("#workspace").html("<a id='myb' href='foo.php' data-role='button'>baz</a>")
                   .button()
                   .click(function() {
                       window.location.href = this.href;
                   });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know of a way to make jQuery Mobile load only on pages
Is there a way to make a collapsible element/set in jQuery Mobile not inset?
Is there a way to make the jquery mobile List divider header be fixed
Is there a way to make jQuery use objects in a conditional statement as
was wondering if there is a way to make superfish using jquery ui theme
Is there a way to make a button's background color change from a color
Is there a way to make my mysql and php server automatically display dates
Is there a way to make the jQuery buttonset buttons smaller?
If I have a link in my jQuery Mobile app, and make it a
How to install jquery mobile application in mobile? Is there a way in which

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.