From 5e2d655d40c0c9062d0a50fb7b01f1dd1bd3765b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 29 Jan 2014 18:24:57 +0000 Subject: [PATCH] only trigger change event for real changes, first initialisation of widget is NOT considered a change this modification might be necessary in more widgets, because they are either not an et2_inputWidget or overwrote set_value method --- etemplate/js/et2_core_inputWidget.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/etemplate/js/et2_core_inputWidget.js b/etemplate/js/et2_core_inputWidget.js index 1fa3be1202..6c1aadde2a 100644 --- a/etemplate/js/et2_core_inputWidget.js +++ b/etemplate/js/et2_core_inputWidget.js @@ -68,7 +68,8 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener], init: function() { this._super.apply(this, arguments); - this._oldValue = ""; + // mark value as not initialised, so set_value can determine if it is necessary to trigger change event + this._oldValue = et2_no_init; this._labelContainer = null; }, @@ -166,13 +167,20 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener], } }, - set_value: function(_value) { - + /** + * Set value of widget and trigger for real changes a change event + * + * First initialisation (_oldValue === et2_no_init) is NOT considered a change! + * + * @param {string} _value value to set + */ + set_value: function(_value) + { var node = this.getInputNode(); if (node) { $j(node).val(_value); - if(this.isAttached()) + if(this.isAttached() && this._oldValue !== et2_no_init && this._oldValue !== _value) { $j(node).change(); }