diff --git a/ietf/secr/static/js/dynamic_inlines.js b/ietf/secr/static/js/dynamic_inlines.js index 9a7c0ed1f..a0b67c591 100644 --- a/ietf/secr/static/js/dynamic_inlines.js +++ b/ietf/secr/static/js/dynamic_inlines.js @@ -28,13 +28,15 @@ function add_inline_form(name) { // check to see if this is a stacked or tabular inline if (first.hasClass("tabular")) { var field_table = first.parent().find('table > tbody') - var count = field_table.children().length - var copy = $('tr:last', field_table).clone(true) + const children = field_table.children('tr.dynamic-inline') + var count = children.length + const last = $(children[count-1]) + var copy = last.clone(true) copy.removeClass("row1 row2") - copy.find("input[name$='address']").removeAttr("readonly") - copy.addClass("row"+((count % 2) == 0 ? 1 : 2)) - field_table.append(copy) - increment_form_ids($('tr:last', field_table), count, name) + copy.find("input[name$='address']").attr("readonly", false) + copy.addClass("row"+((count % 2) ? 2 : 1)) + copy.insertAfter(last) + increment_form_ids($(copy), count, name) } else { var last = $(first).parent().children('.last-related') @@ -54,13 +56,14 @@ function add_inline_form(name) { $(function() { var html_template = '' $('.inline-group').each(function(i) { //prefix is in the name of the input fields before the "-" - var prefix = $("input[type='hidden'][name!='csrfmiddlewaretoken']", this).attr("name").split("-")[0] - $(this).append(html_template.replace("{{prefix}}", prefix)) + var prefix = $("input[type='hidden'][name!='csrfmiddlewaretoken']", this).attr("name").split("-")[0]; + $(this).append(html_template.replace("{{prefix}}", prefix)); + $('#addlink-' + prefix).on('click', () => add_inline_form(prefix)); }) }) diff --git a/ietf/secr/templates/meetings/rooms.html b/ietf/secr/templates/meetings/rooms.html index d3decca80..7d6740e5e 100644 --- a/ietf/secr/templates/meetings/rooms.html +++ b/ietf/secr/templates/meetings/rooms.html @@ -28,7 +28,7 @@ {% if form.non_field_errors %} {{ form.non_field_errors }} {% endif %} - + {% for hidden in form.hidden_fields %} {{ hidden }} diff --git a/ietf/secr/templates/rolodex/edit.html b/ietf/secr/templates/rolodex/edit.html index ee7a4db5e..61f48e5ec 100644 --- a/ietf/secr/templates/rolodex/edit.html +++ b/ietf/secr/templates/rolodex/edit.html @@ -43,7 +43,7 @@ {% for form in email_formset.forms %} {% if form.non_field_errors %}{{ form.non_field_errors }}{% endif %} - + {# Include the hidden fields in the form #} {% for hidden in form.hidden_fields %}