From 01a54413a294bc20dafb76562ffaee9e26ba5671 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 a0bd6fac31..cbe150478f 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() {