From dbf23baa451ac21ad6466a6d0410b86a05bf13a1 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 14 Feb 2021 00:44:36 +0100 Subject: [PATCH] wait for successful ajax call --- htdocs/lib/settings/BookmarkTable.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/lib/settings/BookmarkTable.js b/htdocs/lib/settings/BookmarkTable.js index a311129..b530513 100644 --- a/htdocs/lib/settings/BookmarkTable.js +++ b/htdocs/lib/settings/BookmarkTable.js @@ -19,22 +19,24 @@ $.fn.bookmarktable = function() { if (!$input) return; $input.val($cell.data('value') || html); + $input.prop('disabled', false); $cell.html($input); $input.focus(); var submit = function() { + $input.prop('disabled', true); $.ajax(document.location.href + "/" + $row.data('id'), { data: JSON.stringify(Object.fromEntries([[$input.prop('name'), $input.val()]])), contentType: 'application/json', method: 'POST' + }).then(function(){ + var $option = $input.find('option:selected') + if ($option.length) { + $cell.html($option.html()); + } else { + $cell.html($input.val()); + } }); - - var $option = $input.find('option:selected') - if ($option.length) { - $cell.html($option.html()); - } else { - $cell.html($input.val()); - } }; $input.on('blur', submit).on('change', submit).on('keyup', function(e){