So,
I had a think about this and found a solution for you.
Try this out:
<!DOCTYPE html>
<html>
<head>
<title>Test copy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />-->
<!--<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />-->
<link rel="stylesheet" href="./jquery.mobile-1.3.0.min.css" />
<link rel="stylesheet" href="http://www.mmeinc.com/m/css/mobile.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!--<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>-->
<!--<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>-->
<script src="./jquery.mobile-1.3.1.min.js"></script>
<style type="text/css">
.dynatable {border: solid 1px #000; border-collapse: collapse;}
.dynatable th, .dynatable td {border: solid 1px #000; padding: 2px 10px; width: 33%; text-align: center;}
.dynatable td {background-color:#619FCD;}
</style>
</head>
<body>
<div data-role="page" id="RateWeight">
<form id="RateForm" method="post" action="../rtest.php">
<table class="dynatable">
<thead>
<tr>
<th>Weight (lbs)</th>
<th>Class</th>
<th><button class="add" data-mini="true">Add</button></th>
</tr>
</thead>
<tbody>
<tr class="ItemList">
<td><input class="WgtArr" type="number" maxLength="5" size="9" name="WgtArr[]"></td>
<td class='repeatable'>
<select class="ClArr" name="ClArr[]" id="ClArr">
<option value="0500" selected>50</option>
<option value="0550">55</option>
<option value="0600">60</option>
<option value="0650">65</option>
<option value="0700">70</option>
<option value="0775">77.5</option>
<option value="0850">85</option>
<option value="0925">92.5</option>
<option value="1000">100</option>
<option value="1100">110</option>
<option value="1250">125</option>
<option value="1500">150</option>
<option value="1750">175</option>
<option value="2000">200</option>
<option value="2500">250</option>
<option value="3000">300</option>
<option value="4000">400</option>
<option value="5000">500</option>
</select>
</td>
<td><button class="remove mini" data-mini="true">Remove</button></td>
</tr>
</tbody>
</table>
</form>
</div>
<script type="text/javascript">
function cloneSelect() {
var selectmenu = $.mobile.activePage.find('select').last().clone(),
index = $.mobile.activePage.find('select').last().index()+1,
id = $.mobile.activePage.find('select').last().attr('id');
$('.holder').last().append(selectmenu.attr('id',id+index));
$('#'+id+index).selectmenu();
}
$("table.dynatable button.add").click(function(e){
e.preventDefault();
var w = $(".ItemList td").first().clone();
var c = $("<td class='holder'></td>");
var b = $(".ItemList td").last().clone();
var t = $('<tr class="ItemList">').append(w).append(c).append(b);
$("tbody").append(t);
cloneSelect();
$("table.dynatable button.remove").live("click", function(){
$(this).parents("tr").remove();
});
});
</script>
</body>
</html>
Apologies for the multiple inclusions of jQuery mobile, but when I was testing this, I kept getting time out errors.
Anyway, how this works is as follows:
As I mentioned, clones of expandable items are a bit tricky in jQuery mobile.
We therefore have to clone all of the cells separately, creating a place holder for the select. We then append the cloned cells to a table row, which we then append to the table body.
After that has been done, we are then in a position to reference the last select (and only the select, not the additional HTML that jQuery mobile wraps around it), increment its id, then, referencing it by its new id, apply the .selectmenu()
method to it.
Hope that helps you.
Reference: http://stackoverflow.com/questions/9150444/jquery-clone-selectmenu-in-table