Merge an old stash allowing passing an alternate buttonconfig parameter to show/get Modal

This commit is contained in:
Isaac Connor 2021-06-12 11:58:06 -04:00
parent 7878fbc878
commit af46f8cad5
1 changed files with 10 additions and 2 deletions

View File

@ -781,7 +781,7 @@ function logAjaxFail(jqxhr, textStatus, error) {
} }
// Load the Modal HTML via Ajax call // Load the Modal HTML via Ajax call
function getModal(id, parameters) { function getModal(id, parameters, buttonconfig=null) {
$j.getJSON(thisUrl + '?request=modal&modal='+id+'&'+parameters) $j.getJSON(thisUrl + '?request=modal&modal='+id+'&'+parameters)
.done(function(data) { .done(function(data) {
if ( !data ) { if ( !data ) {
@ -790,7 +790,7 @@ function getModal(id, parameters) {
} }
insertModalHtml(id, data.html); insertModalHtml(id, data.html);
manageModalBtns(id); buttonconfig ? buttonconfig() : manageModalBtns(id);
modal = $j('#'+id+'Modal'); modal = $j('#'+id+'Modal');
if ( ! modal.length ) { if ( ! modal.length ) {
console.log('No modal found'); console.log('No modal found');
@ -800,6 +800,14 @@ function getModal(id, parameters) {
.fail(logAjaxFail); .fail(logAjaxFail);
} }
function showModal(id, buttonconfig=null) {
var div = $j('#'+id+'Modal');
if ( ! div.length ) {
getModal(id, buttonconfig);
}
div.modal('show');
}
function manageModalBtns(id) { function manageModalBtns(id) {
// Manage the CANCEL modal button, note data-dismiss="modal" would work better // Manage the CANCEL modal button, note data-dismiss="modal" would work better
var cancelBtn = document.getElementById(id+"CancelBtn"); var cancelBtn = document.getElementById(id+"CancelBtn");