Filter: introduce timeout (still does not work as expected)

This commit is contained in:
rolux 2014-02-10 09:15:03 +00:00
parent 6bad3345da
commit e763541eea

View file

@ -378,8 +378,8 @@ Ox.Filter = function(options, self) {
function changeConditionValue(pos, subpos, value) { function changeConditionValue(pos, subpos, value) {
Ox.Log('FILTER', 'cCV', pos, subpos, value); Ox.Log('FILTER', 'cCV', pos, subpos, value);
var condition = subpos == -1 var condition = subpos == -1
? self.options.query.conditions[pos] ? self.options.query.conditions[pos]
: self.options.query.conditions[pos].conditions[subpos]; : self.options.query.conditions[pos].conditions[subpos];
condition.value = value; condition.value = value;
triggerChangeEvent(); triggerChangeEvent();
} }
@ -490,15 +490,20 @@ Ox.Filter = function(options, self) {
.css({margin: '0 ' + (subpos == -1 ? '4px' : '0') + ' 0 4px'}) .css({margin: '0 ' + (subpos == -1 ? '4px' : '0') + ' 0 4px'})
.bindEvent({ .bindEvent({
click: function(data) { click: function(data) {
Ox.Log('Form', 'add...', data, this.$element.parent().data('position'), this.$element.parent().data('subposition')) var that = this;
if (this.$element.parent().data('subposition') == -1) { // timeout needed so that input change registers
addCondition(this.$element.parent().data('position') + 1); // before all conditions are re-rendered
} else { setTimeout(function() {
addCondition( Ox.Log('Form', 'add...', data, that.$element.parent().data('position'), that.$element.parent().data('subposition'))
this.$element.parent().data('position'), if (that.$element.parent().data('subposition') == -1) {
this.$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 ? [ ], subpos == -1 ? [
@ -511,7 +516,10 @@ Ox.Filter = function(options, self) {
.css({margin: '0 0 0 4px'}) .css({margin: '0 0 0 4px'})
.bindEvent({ .bindEvent({
click: function(data) { 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)
});
} }
}) })
] : []); ] : []);