Below is HTML/JQuery code sample. I would like to clone a "select". The "select" is indeed cloned (BTW, twice for some reason, which is another question) but when using the mouse to select an item from the list of options, the item is not selected and not updated in the UI.
Would be great to get some tips on this.
<body>
<div>
<form action="" method="POST" id="id_of_form">
<div id="id_div_selection_options">
<select id="id_selection_options">
<option value="a">a</option>
<option value="b">b</option>
</select>
</div>
</form>
</div>
<p>
<a id="add" href="#" data-role="button" data-icon="plus">Add another item</a>
</p>
</body>
{% block extra-js %}
<script>
$(document).ready(function() {
function addEntry(btn) {
var cloned = $('#id_div_selection_options').clone();
cloned.attr('id', 'id_of_dup');
cloned.appendTo($("#id_of_form"));
}
// Register the click event handlers
$("#add").click(function() {
return addEntry(this);
});
});
</script>
{% endblock extra-js %}
TX Guy