summaryrefslogtreecommitdiffstats
path: root/ogcp/static
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-10 12:39:11 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-10 16:21:21 +0200
commita04ef4e421ec29a3fb2f8181b5c7af381767001c (patch)
treef97291fce53c2f1e440d0db1ec36f3a24eca1ae0 /ogcp/static
parent0ba0b933e2483434fab77c8130960af3901a6190 (diff)
js: fix id update in partition form deletion
Update all the name and id fields of the elements in the partition form after a delete operation. Inconsistent ids make form.validate() to always return False, this causes all the form validation code to be skipped.
Diffstat (limited to 'ogcp/static')
-rw-r--r--ogcp/static/js/ogcp.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js
index ccd8a1e..4779bf4 100644
--- a/ogcp/static/js/ogcp.js
+++ b/ogcp/static/js/ogcp.js
@@ -325,10 +325,12 @@ function RemovePartition(evt) {
target.remove();
// Reassign rows ids
table.find('tr').each(function(index) {
- $(this).find('.form-control').each(function() {
+ function update_references() {
const id = $(this).attr('id').replace(/(.*)-(\d{1,4})-(.*)/, `$1-${index}-$3`);
$(this).attr('name', id).attr('id', id);
- });
+ }
+ $(this).find('input').filter(':first').each(update_references);
+ $(this).find('.form-control').each(update_references);
});
} else {
table.find('tr').each(function(index) {