Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion public/main/lp/learnpath.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5710,7 +5710,27 @@ public function displayDocumentForm($action = 'add', $lpItem = null)

$form->addButtonSave(get_lang('Save'), 'submit_button');

return $form->returnForm();
$script = '<script>
document.addEventListener("DOMContentLoaded", function () {
var form = document.getElementById("form") || document.forms["form"];
if (!form) return;
form.addEventListener("submit", function (e) {
var btn = form.querySelector("button[name=submit_button], input[name=submit_button]");
if (!btn) return;
// async disable to avoid interfering with possible sync handlers triggered on submit
setTimeout(function () {
try {
btn.disabled = true;
if (btn.classList) btn.classList.add("disabled");
} catch (err) {
// silent
}
}, 0);
}, { once: true }); // once: true to disable only on the first submit
});
</script>';

return $form->returnForm() . $script;
}

/**
Expand Down
Loading