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) {
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)
});
}
})
] : []);