Modal form improvements

This commit is contained in:
Oliver 2021-07-09 01:20:40 +10:00
parent ecf47aa69d
commit 337223b8eb
2 changed files with 22 additions and 4 deletions

View File

@ -732,11 +732,31 @@ function handleFormSuccess(response, options) {
// Close the modal
if (!options.preventClose) {
// TODO: Actually just *delete* the modal,
// rather than hiding it!!
// Note: The modal will be deleted automatically after closing
$(options.modal).modal('hide');
}
// Display any required messages
// Should we show alerts immediately or cache them?
var cache = (options.follow && response.url) || options.redirect || options.reload;
// Display any messages
if (response.success) {
showAlertOrCache("alert-success", response.success, cache);
}
if (response.info) {
showAlertOrCache("alert-info", response.info, cache);
}
if (response.warning) {
showAlertOrCache("alert-warning", response.warning, cache);
}
if (response.danger) {
showAlertOrCache("alert-danger", response.danger, cache);
}
if (options.onSuccess) {
// Callback function
options.onSuccess(response, options);

View File

@ -83,8 +83,6 @@ function createNewModal(options={}) {
// Capture "enter" key input
$(modal_name).on('keydown', 'input', function(event) {
if (event.keyCode == 13) {
event.preventDefault();
// Simulate a click on the 'Submit' button