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

@ -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
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 { } else {
addCondition( addCondition(
this.$element.parent().data('position'), that.$element.parent().data('position'),
this.$element.parent().data('subposition') + 1 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)
});
} }
}) })
] : []); ] : []);