Commit 7b202460 authored by Clement Ho's avatar Clement Ho

Fix ajax bug

parent 98a95633
......@@ -31,18 +31,13 @@ if ( typeof CustomEvent === "function" ) {
var CustomEvent = require('./custom_event_polyfill');
var utils = require('./utils');
var DropDown = function(list, trigger) {
var DropDown = function(list) {
this.hidden = true;
this.list = list;
this.trigger = trigger;
this.items = [];
this.getItems();
this.addEvents();
this.initialState = list.innerHTML;
if (this.initialState.indexOf('{{') == -1) {
debugger
}
};
Object.assign(DropDown.prototype, {
......
......@@ -5,6 +5,7 @@
require('../window')(function(w){
w.droplabAjaxFilter = {
init: function(hook) {
this.destroyed = false;
this.hook = hook;
this.notLoading();
......@@ -49,14 +50,16 @@ require('../window')(function(w){
}
this.loading = true;
this.hook.list.setData([]);
var params = config.params || {};
params[config.searchKey] = searchValue;
var self = this;
this._loadUrlData(config.endpoint + this.buildParams(params)).then(function(data) {
self.hook.restoreInitialState.call(self.hook);
self.hook.list.setData.call(self.hook.list, data[0]);
if (!self.destroyed) {
self.hook.list.setData.call(self.hook.list, data[0]);
}
self.notLoading();
});
},
......@@ -92,6 +95,8 @@ require('../window')(function(w){
clearTimeout(this.timeout);
}
this.destroyed = true;
this.hook.trigger.removeEventListener('keydown.dl', this.debounceTriggerWrapper);
this.hook.trigger.removeEventListener('focus', this.debounceTriggerWrapper);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment