in xf/src/xf.view.js [88:158]
load: function() {
if (this.template.src) {
this.status.loading = false;
this.status.loaded = true;
this.trigger('loaded');
return;
}
var url = (_.isFunction(this.url)) ? this.url() : this.url;
if (!url) {
this.status.loadingFailed = true;
this.trigger('loaded');
return;
}
// trying to get template from cache
console.log(111, XF.settings.noCache);
if (!XF.settings.noCache) {
console.log(this.template.cache, _.has(XF, 'storage'));
if (this.template.cache && _.has(XF, 'storage')) {
var cachedTemplate = XF.storage.get(url);
if (cachedTemplate) {
this.template.src = cachedTemplate;
this.status.loaded = true;
this.trigger('loaded');
return;
}
}
}
if (!this.status.loaded && !this.status.loading) {
this.status.loading = true;
var $this = this;
Dom.ajax({
url: url,
complete: function(jqXHR, textStatus) {
if (!$this.component) {
throw 'XF.View "component" linkage lost';
}
if (textStatus == 'success') {
var template = jqXHR.responseText;
// saving template into cache if the option is turned on
if (!XF.settings.noCache) {
if ($this.template.cache && _.has(XF, 'storage')) {
XF.storage.set(url, template);
}
}
$this.template.src = jqXHR.responseText;
$this.status.loading = false;
$this.status.loaded = true;
$this.afterLoadTemplate();
$this.trigger('loaded');
} else {
$this.template.src = null;
$this.status.loading = false;
$this.status.loaded = false;
$this.status.loadingFailed = true;
$this.afterLoadTemplateFailed();
$this.trigger('loaded');
}
}
});
}
},