Merge branch 'elarnon/fix-182' into 'master'

Properly propagate the default number of places in tirage

Closes #182

See merge request cof-geek/gestioCOF!295
This commit is contained in:
Martin Pepin 2018-02-20 14:40:20 +01:00
commit 307c48ca76

View file

@ -27,6 +27,14 @@ var django = {
var newFor = $(this).attr('for').replace('-' + (total-1) + '-','-' + total + '-');
$(this).attr('for', newFor);
});
// Cloning <select> element doesn't properly propagate the default
// selected <option>, so we set it manually.
newElement.find('select').each(function (index, select) {
var defaultValue = $(select).find('option[selected]').val();
if (typeof defaultValue !== 'undefined') {
$(select).val(defaultValue);
}
});
total++;
$('#id_' + type + '-TOTAL_FORMS').val(total);
$(selector).after(newElement);