Commit 0421793b authored by Phil Hughes's avatar Phil Hughes

Correctly resets the default template on destroy

parent 99d5838f
...@@ -29,6 +29,7 @@ require('../window')(function(w){ ...@@ -29,6 +29,7 @@ require('../window')(function(w){
init: function init(hook) { init: function init(hook) {
var self = this; var self = this;
var config = hook.config.droplabAjax; var config = hook.config.droplabAjax;
this.hook = hook;
if (!config || !config.endpoint || !config.method) { if (!config || !config.endpoint || !config.method) {
return; return;
...@@ -52,15 +53,15 @@ require('../window')(function(w){ ...@@ -52,15 +53,15 @@ require('../window')(function(w){
this._loadUrlData(config.endpoint) this._loadUrlData(config.endpoint)
.then(function(d) { .then(function(d) {
if (config.loadingTemplate) { if (config.loadingTemplate) {
var dataLoadingTemplate = hook.list.list.querySelector('[data-loading-template]'); var dataLoadingTemplate = self.hook.list.list.querySelector('[data-loading-template]');
if (dataLoadingTemplate) { if (dataLoadingTemplate) {
dataLoadingTemplate.outerHTML = self.listTemplate; dataLoadingTemplate.outerHTML = self.listTemplate;
} }
} }
if (!hook.list.hidden) { if (!self.hook.list.hidden) {
hook.list[config.method].call(hook.list, d); self.hook.list[config.method].call(self.hook.list, d);
} }
}).catch(function(e) { }).catch(function(e) {
throw new droplabAjaxException(e.message || e); throw new droplabAjaxException(e.message || e);
...@@ -68,6 +69,10 @@ require('../window')(function(w){ ...@@ -68,6 +69,10 @@ require('../window')(function(w){
}, },
destroy: function() { destroy: function() {
if (this.listTemplate) {
var dynamicList = this.hook.list.list.querySelector('[data-dynamic]');
dynamicList.outerHTML = this.listTemplate;
}
} }
}; };
}); });
......
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