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

  • Home
  • SEARCH
  • 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 8707559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:53:54+00:00 2026-06-13T03:53:54+00:00

I’m using the .clone() function of jQuery Mobile to clone a div in a

  • 0

I’m using the .clone() function of jQuery Mobile to clone a div in a form so I can have repeatable sections, but now I have a problem with nested selects.
Once the div is cloned and the nested selects are updated with the new id, something strange happens after the next ‘refresh’.

What happens is very strange, the select just double and place itself inside the existing select, so the result is this:

Strange behavior with JQM and cloned selects

The browser is Safari, I’ve not made any test with other browser because I only need this code working on Safari.

What I do to clone the div is:

var div = $.mobile.activePage.find('.repeatable').last().clone();

to clone, then I update the IDs:

var newValue = pid +'-' + index;
$(this).attr('id', newValue);
$("label[for='"+ old +"']").attr('for', newValue);

and, at the end, I refresh all selects to have the right value selected once .val() is called:

if ($(this).data('role') === 'select') {
    $(this).selectmenu();
    $(this).selectmenu('refresh');
}

The problem happens when the last part of the code is called. Before the select shows correctly, but doesn’t work properly, once the select is refreshed, it starts working in the right way, but the UI is messed because has been doubled and placed as child of the original element.

I add the div in the following way, before the clone button:

$('#clone_button').before(div);

What can be the origin of this problem?

Edit: It looks like this could be a bug of jQuery Mobile: example.

  • 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-13T03:53:55+00:00Added an answer on June 13, 2026 at 3:53 am

    I finally found out a workaround to this problem.
    At the moment, clones of expandable items are not supported by jQuery mobile.

    The only way to do this, is to edit and fix manually the cloned div, deleting style items around selects and isolating them.

    What we’ve to do is pretty simple, but tricky:

    • Navigate all DIVs with class ui-select
    • Extrapolate the nested SELECT removing useless tags
    • Append the HTML code of the SELECT after or before the ui-select DIV
    • Remove the ui-select DIV
    • Append the repeatable DIV
    • Call trigger('create') in the parent to re-generate the correct style.

    It’s messy, but it works.

    I’ve updated the example in JSFiddle. (edit: another good solution from arschmitz on JSFiddle)

    P.S. If you’re using labels you’ve to save them somewhere and re-append them in the correct position.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.