add data-ajax-submit to email-test-modal

This commit is contained in:
Felix Hamann 2019-02-20 08:43:43 +01:00
parent a91bc3388f
commit b8eb78d11a
2 changed files with 4 additions and 3 deletions

View File

@ -77,7 +77,7 @@ postAdminTestR = do
(FormFailure errs) -> forM_ errs $ addMessage Error . toHtml
let emailWidget' = [whamlet|
<form method=post action=@{AdminTestR} enctype=#{emailEnctype}>
<form method=post action=@{AdminTestR} enctype=#{emailEnctype} data-ajax-submit>
^{emailWidget}
|]

View File

@ -10,6 +10,7 @@
var OVERLAY_CLASS = 'modal__overlay';
var OVERLAY_OPEN_CLASS = 'modal__overlay--open';
var CLOSER_CLASS = 'modal__closer';
var AJAX_SUBMIT_FLAG = 'ajaxSubmit'
window.utils.modal = function(modalElement, options) {
@ -40,7 +41,7 @@
document.body.insertBefore(modalElement, null);
var form = modalElement.querySelector('form');
if (form) {
if (form && AJAX_SUBMIT_FLAG in form.dataset) {
setupForm(form);
}
@ -75,7 +76,7 @@
}).then(function(response) {
// TODO: process json response once backend returns json
}).catch(function(error) {
console.error('could not fetch or process response from ' + url, error);
console.error('could not fetch or process response from ' + url, { error });
});
});
}