Provide an after_render callback

- User callback after the form data are rendered
This commit is contained in:
Oliver Walters 2019-05-14 19:00:59 +10:00
parent 57645486cc
commit 0cc2e71843

View File

@ -401,6 +401,10 @@ function handleModalForm(url, options) {
else { else {
if (response.html_form) { if (response.html_form) {
injectModalForm(modal, response.html_form); injectModalForm(modal, response.html_form);
if (options.after_render) {
options.after_render(modal, response);
}
} }
else { else {
$(modal).modal('hide'); $(modal).modal('hide');
@ -443,6 +447,7 @@ function launchModalForm(url, options = {}) {
* submit_text - Text for the submit button (default = 'Submit') * submit_text - Text for the submit button (default = 'Submit')
* close_text - Text for the close button (default = 'Close') * close_text - Text for the close button (default = 'Close')
* no_post - If true, only display form data, hide submit button, and disallow POST * no_post - If true, only display form data, hide submit button, and disallow POST
* after_render - Callback function to run after form is rendered
*/ */
var modal = options.modal || '#modal-form'; var modal = options.modal || '#modal-form';
@ -475,6 +480,10 @@ function launchModalForm(url, options = {}) {
if (response.html_form) { if (response.html_form) {
injectModalForm(modal, response.html_form); injectModalForm(modal, response.html_form);
if (options.after_render) {
options.after_render(modal, response);
}
if (options.no_post) { if (options.no_post) {
modalShowSubmitButton(modal, false); modalShowSubmitButton(modal, false);
} else { } else {