Fixes for double-submit on butons

- Function that first unbinds the submit button
This commit is contained in:
Oliver 2018-05-08 22:49:23 +10:00
parent bf4ffb8b0b
commit fdf35bd741
2 changed files with 12 additions and 6 deletions

View File

@ -65,6 +65,15 @@ function closeModal(modal='#modal-form') {
$(modal).modal('hide');
}
function modalSubmit(modal, callback) {
$(modal).off('click', '#modal-form-submit');
$(modal).on('click', '#modal-form-submit', function() {
callback();
});
}
function openModal(options) {
var modal = options.modal || '#modal-form';
@ -188,10 +197,7 @@ function handleModalForm(url, options) {
return false;
});
// Un-bind any attached click listeners
$(modal).off('click', '#modal-form-submit');
$(modal).on('click', '#modal-form-submit', function() {
modalSubmit(modal, function() {
$(modal).find('.js-modal-form').ajaxSubmit({
url: url,
// POST was successful

View File

@ -102,7 +102,7 @@ function updateStock(items, options={}) {
content: html
});
$(modal).on('click', '#modal-form-submit', function() {
modalSubmit(modal, function() {
var stocktake = [];
@ -244,7 +244,7 @@ function moveStockItems(items, options) {
modalSetContent(modal, html);
attachSelect(modal);
$(modal).on('click', '#modal-form-submit', function() {
modalSubmit(modal, function() {
var locId = $(modal).find("#stock-location").val();
doMove(locId, parts);