From e763541eeaadfdf3b5b5fc89228afe39ac843f13 Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 10 Feb 2014 09:15:03 +0000 Subject: [PATCH] Filter: introduce timeout (still does not work as expected) --- source/Ox.UI/js/Form/Filter.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/source/Ox.UI/js/Form/Filter.js b/source/Ox.UI/js/Form/Filter.js index 528803d4..20d02bd1 100644 --- a/source/Ox.UI/js/Form/Filter.js +++ b/source/Ox.UI/js/Form/Filter.js @@ -378,8 +378,8 @@ Ox.Filter = function(options, self) { function changeConditionValue(pos, subpos, value) { Ox.Log('FILTER', 'cCV', pos, subpos, value); var condition = subpos == -1 - ? self.options.query.conditions[pos] - : self.options.query.conditions[pos].conditions[subpos]; + ? self.options.query.conditions[pos] + : self.options.query.conditions[pos].conditions[subpos]; condition.value = value; triggerChangeEvent(); } @@ -490,15 +490,20 @@ Ox.Filter = function(options, self) { .css({margin: '0 ' + (subpos == -1 ? '4px' : '0') + ' 0 4px'}) .bindEvent({ click: function(data) { - Ox.Log('Form', 'add...', data, this.$element.parent().data('position'), this.$element.parent().data('subposition')) - if (this.$element.parent().data('subposition') == -1) { - addCondition(this.$element.parent().data('position') + 1); - } else { - addCondition( - this.$element.parent().data('position'), - this.$element.parent().data('subposition') + 1 - ); - } + var that = this; + // timeout needed so that input change registers + // before all conditions are re-rendered + setTimeout(function() { + Ox.Log('Form', 'add...', data, that.$element.parent().data('position'), that.$element.parent().data('subposition')) + if (that.$element.parent().data('subposition') == -1) { + addCondition(that.$element.parent().data('position') + 1); + } else { + addCondition( + that.$element.parent().data('position'), + that.$element.parent().data('subposition') + 1 + ); + } + }); } }) ], subpos == -1 ? [ @@ -511,7 +516,10 @@ Ox.Filter = function(options, self) { .css({margin: '0 0 0 4px'}) .bindEvent({ click: function(data) { - addCondition(this.$element.parent().data('position') + 1, -1, true) + var that = this; + setTimeout(function() { + addCondition(that.$element.parent().data('position') + 1, -1, true) + }); } }) ] : []);