From 95a6625f05b71501e3f922797afeb17ab2114fc3 Mon Sep 17 00:00:00 2001 From: Mantas Masalskis Date: Wed, 24 Mar 2021 08:39:07 +0000 Subject: [PATCH] Fixes #3463 - After calling the delete or clone dialog three times, two modal dialogs appear in succession --- .../_application_controller/table.coffee | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller/table.coffee b/app/assets/javascripts/app/controllers/_application_controller/table.coffee index f95f49df0..9ca732ac2 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/table.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/table.coffee @@ -844,13 +844,20 @@ class App.ControllerTable extends App.Controller toggleActionDropdown: (id, e, td) => e.stopPropagation() $dropdown = $(td).find('.js-table-action-menu') + if $dropdown.length + # open dropdown $dropdown.dropdown('toggle') + + # check if bind to open dropdown is already done + return if $dropdown.prop('rendered') + + # remember that bind to open dropdown is already done + $dropdown.prop('rendered', true) + # bind on click now that the dropdown is open - $dropdown.one('click.dropdown', '[data-table-action]', @onActionButtonClicked) - # unbind after dropdown is closed - $dropdown.parent().one('hide.bs.dropdown', -> $dropdown.off('click.dropdown')) + $dropdown.on('click.dropdown', '[data-table-action]', @onActionButtonClicked) else # only one action - directly fire that action name = $(td).find('[data-table-action]').attr('data-table-action')