Skip to content

Commit

Permalink
Commented out periodical update stuff in CDD filter JS, don't understamd
Browse files Browse the repository at this point in the history
why it's there, and it has some really nasty side effects - basically
fires off half a dozen AJAX updates on page load, regardless of how fast
the first one comes back.
  • Loading branch information
cheesegrits committed Dec 2, 2015
1 parent a1e41b1 commit 14c69cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Expand Up @@ -1066,6 +1066,12 @@ public function filterJS($normal, $container)
{
$params = $this->getParams();
$default = $this->getDefaultFilterVal($normal);

if ($default === '')
{
$default = $params->get('cascadingdropdown_noselectionvalue', '');
}

$filterId = $this->getHTMLId() . 'value';
FabrikHelperHTML::script('plugins/fabrik_element/cascadingdropdown/filter.js');
$opts = new stdClass;
Expand Down
2 changes: 1 addition & 1 deletion plugins/fabrik_element/cascadingdropdown/filter-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions plugins/fabrik_element/cascadingdropdown/filter.js
Expand Up @@ -38,6 +38,7 @@ var CascadeFilter = new Class({
});

this.observer.addEvent('change', function () {
/*
this.periodcount = 0;
document.id(this.options.filterid + '_loading').setStyle('opacity', '1');
var v = this.observer.get('value');
Expand All @@ -46,11 +47,14 @@ var CascadeFilter = new Class({
$filterData = eval(this.options.filterobj).getFilterData();
Object.append(this.myAjax.options.data, $filterData);
this.myAjax.send();
*/
this.update();
}.bind(this));

v = this.observer.get('value');
this.periodical = this.update.periodical(500, this);
this.periodcount = 0;
//v = this.observer.get('value');
//this.periodical = this.update.periodical(500, this);
//this.periodcount = 0;
this.update();
} else {
fconsole('observer not found ', observerid);
}
Expand All @@ -68,11 +72,13 @@ var CascadeFilter = new Class({

ajaxComplete: function (json) {
json = JSON.decode(json);
/*
this.periodcount ++;
if (this.periodcount > 5) {
this.endAjax();
return;
}
*/
if (typeOf(document.id(this.options.filterid)) === 'null') {
fconsole('filterid not found: ', this.options.filterid);
this.endAjax();
Expand All @@ -83,19 +89,22 @@ var CascadeFilter = new Class({
json.each(function (item) {
new Element('option', {'value': item.value}).appendText(item.text).inject(document.id(this.options.filterid));
}.bind(this));
/*
if (json.length > 0) {
if ((json.length === 1 && json[0].value === this.options.noselectionvalue) === false) {
if (!this.setupDone && (json.length === 1 && json[0].value === this.options.noselectionvalue) === false) {
this.endAjax();
}
} else {
this.endAjax();
}
*/
this.endAjax();
},

endAjax: function ()
{
document.id(this.options.filterid + '_loading').setStyle('opacity', '0');
clearInterval(this.periodical);
//clearInterval(this.periodical);
document.id(this.options.filterid).value = this.options.def;
if (this.options.advanced)
{
Expand Down

0 comments on commit 14c69cd

Please sign in to comment.