I need help of javascript / jquery experts to solve the next problem:
---- 1. this javascript alerts the id of a selected option in a select html tag:
$(function(){
$("#id_productos_list").change(
function(){
var op = $(this).selectedValues()
alert(op);
}
);
});
----2. this javascript clone html code:
function cloneMore(selector, type) {
var newElement = $(selector).clone();
var total = $('#id_' + type + '-TOTAL_FORMS').val();
newElement.find(':input').each(function() {
var name = $(this).attr('name').replace('-' + (total-1) + '-','-' + total + '-');
var id = 'id_' + name;
$(this).attr({'name': name, 'id': id}).val('').removeAttr('checked');
});
newElement.find('label').each(function() {
var newFor = $(this).attr('for').replace('-' + (total-1) + '-','-' + total + '-');
$(this).attr('for', newFor);
});
total++;
$('#id_' + type + '-TOTAL_FORMS').val(total);
$(selector).after(newElement);
}
---- this is a part of the HTML code that JS is cloning, and it works with no problems
<select id="id_productos_list" name="productos_list" >
<option value="1">One</option>
<option value="2">Two</option>
</select>
BUT just the javascript #1 works with the initial html code (original for clone). the cloned others doesnt alert selected options. I've tested with diferents id's attrs for each cloned select tags, without results.
What im missing? firebug display the cloned html DOM nice :S Do I have to update DOM after cloning to make $("#id productos list").change(...) works?