mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-04 20:51:00 +00:00
Added AjaxUpdateView class
Also cleaned up the modal form javascript
This commit is contained in:
@ -1,28 +1,25 @@
|
||||
/* Bind a button to launch a modal form and handle AJAX requests */
|
||||
function bindModalForm(modal, button, url, data) {
|
||||
$(button).click(function () {
|
||||
$.ajax({
|
||||
url: url, // Where to request the data from
|
||||
type: 'get', // GET request
|
||||
data: data, // Any additional context data (e.g. initial values)
|
||||
dataType: 'json',
|
||||
beforeSend: function() {
|
||||
$(modal).modal('show');
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.html_form) {
|
||||
var target = modal + ' .modal-content';
|
||||
$(target).html(response.html_form);
|
||||
} else {
|
||||
alert('JSON response missing form data');
|
||||
$(modal).modal('hide');
|
||||
}
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
alert('Error requesting form data:\n' + thrownError);
|
||||
function launchModalForm(modal, url, data) {
|
||||
$.ajax({
|
||||
url: url, // Where to request the data from
|
||||
type: 'get', // GET request
|
||||
data: data, // Any additional context data (e.g. initial values)
|
||||
dataType: 'json',
|
||||
beforeSend: function() {
|
||||
$(modal).modal('show');
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.html_form) {
|
||||
var target = modal + ' .modal-content';
|
||||
$(target).html(response.html_form);
|
||||
} else {
|
||||
alert('JSON response missing form data');
|
||||
$(modal).modal('hide');
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
alert('Error requesting form data:\n' + thrownError);
|
||||
$(modal).modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$(modal).on('submit', '.js-modal-form', function() {
|
||||
|
Reference in New Issue
Block a user