5 function cloneMore(selector, type) {
6 var newElement = $(selector).clone(true);
7 var total = $('#id_' + type + '-TOTAL_FORMS').val();
8 newElement.find(':input').each(function() {
9 var name = $(this).attr('name').replace('__prefix__', total);
10 var id = 'id_' + name;
11 $(this).attr({'name': name, 'id': id});
13 newElement.find('label').each(function() {
14 var newFor = $(this).attr('for').replace('__prefix__', total);
15 $(this).attr('for', newFor);
17 newElement.attr({'style': '', 'id': ''});
19 $('#id_' + type + '-TOTAL_FORMS').val(total);
20 $(selector).before(newElement);
25 $('.add_more').click(function() {
26 cloneMore($(this).data('selector'), $(this).data('prefix'));