datatracker/ietf/static/js/status-change-edit-relations.js
Lars Eggert 66533827e1
fix: Fix status change form (#4598)
* fix: Fix status change form

Also make it so that select2 search fields get focus when they open.

* Remove feat
2022-10-18 09:59:04 -05:00

34 lines
1.1 KiB
JavaScript

$(document)
.ready(function () {
var form = $(".new-relation-row")
.closest("form");
var newRowHtml = form.find(".new-relation-row")
.get(0)
.outerHTML;
var counter = 1;
form.on("click", ".delete", function (e) {
e.preventDefault();
$(this)
.closest(".input-group")
.remove();
});
form.on("keydown change", ".new-relation-row select", function () {
var top = $(this)
.closest(".new-relation-row");
top.removeClass("new-relation-row");
top.find(".delete")
.prop('disabled', false)
.removeClass("btn-outline-danger")
.addClass("btn-danger");
top.find("input,select")
.each(function () {
this.name += counter;
});
++counter;
top.after(newRowHtml);
setupSelect2Field(form.find(".new-relation-row .select2-field"));
});
});