summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 1b96d585ac7..e6e5e84577e 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -45,7 +45,7 @@ var DebouncedField = AbstractField.extend({
this._super.apply(this, arguments);
if (this.DEBOUNCE && this.mode === 'edit') {
- this._onInput = _.debounce(this._onInput.bind(this), this.DEBOUNCE);
+ this._doDebouncedAction = _.debounce(this._doDebouncedAction.bind(this), this.DEBOUNCE);
}
},
@@ -63,6 +63,15 @@ var DebouncedField = AbstractField.extend({
*/
_getValue: function () {
},
+ /**
+ * Notifies the outside world of the new value (checked from the DOM).
+ * This method is debounced so that onchanges are not triggered too quickly.
+ *
+ * @private
+ */
+ _doDebouncedAction: function () {
+ this._setValue(this._getValue());
+ },
//--------------------------------------------------------------------------
// Handlers
@@ -70,7 +79,7 @@ var DebouncedField = AbstractField.extend({
/**
* We immediately notify the outside world when this field confirms its
- * changes
+ * changes.
*
* @private
*/
@@ -78,13 +87,14 @@ var DebouncedField = AbstractField.extend({
this._setValue(this._getValue());
},
/**
- * We notify the outside world for each change in this field. It does not
- * necessarily mean that onchanges will be triggered instantly.
+ * Called when the user is typing text -> By default this only calls a
+ * debounced method to notify the outside world of the changes.
+ * @see _doDebouncedAction
*
* @private
*/
_onInput: function () {
- this._setValue(this._getValue());
+ this._doDebouncedAction();
},
});