From 8105090e39f9f571301b733fc112bae9da0bb98c Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 12 Oct 2018 11:29:21 +0200 Subject: [PATCH] Unbind events after widget gets cleared from DOM to avoid calling events like onchange for second time (eg. infolog projectmanager selection) --- api/js/etemplate/et2_widget_link.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/js/etemplate/et2_widget_link.js b/api/js/etemplate/et2_widget_link.js index 470722673c..f40fb76f83 100644 --- a/api/js/etemplate/et2_widget_link.js +++ b/api/js/etemplate/et2_widget_link.js @@ -590,6 +590,13 @@ var et2_link_entry = (function(){ "use strict"; return et2_inputWidget.extend( this.request = null; this.createInputWidget(); + var self = this; + + jQuery(this.getInstanceManager().DOMContainer).on('clear', function(){ + // We need to unbind events to prevent a second triggerd event handler + // (eg. setting a project in infolog edit dialog) when the widget gets cleared. + jQuery(self.getDOMNode()).off(); + }); }, destroy: function() {