From f45105c3ed6253bfc82e1a12511119924ece983f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 30 Jan 2017 14:43:46 +0100 Subject: [PATCH] fix select(-account) tags=true widget to not call onchange callback twice with different signature, now signature is onchange(_node, _widget, _change) --- api/js/etemplate/et2_widget_selectbox.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/et2_widget_selectbox.js b/api/js/etemplate/et2_widget_selectbox.js index 68a015bcbd..540df025f2 100644 --- a/api/js/etemplate/et2_widget_selectbox.js +++ b/api/js/etemplate/et2_widget_selectbox.js @@ -709,8 +709,21 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend( inherit_select_classes: true, search_contains: true, width: _width || size.w + "px" - }) - .change(this.onchange); + }); + + if(this.options.onchange) + { + // Unbind change handler of widget's ancestor to stop it from bubbling + // chosen has its own onchange + jQuery(this.input).unbind('change.et2_inputWidget'); + + var self = this; + this.input.chosen().change(function(_ev, _change) + { + // enhance signature of regular et2_selectbox.onchange with 3. parameter from chosen + self.change.call(self, self.input, self, _change); + }); + } // multi selection with limited show line of single row if (this.options.multiple && this.options.rows == 1 && this.options.height)