Browse Source

#2534 - adds new DOM caching, which preserves events and final rendered state

pull/4701/head
Jack Lukic 8 years ago
parent
commit
d095ed18f1
1 changed files with 24 additions and 6 deletions
  1. 30
      src/definitions/modules/tab.js

30
src/definitions/modules/tab.js

@ -429,13 +429,21 @@ $.fn.tab = function(parameters) {
? evaluateScripts
: settings.evaluateScripts
;
if(evaluateScripts) {
module.debug('Updating HTML and evaluating inline scripts', tabPath, html);
$tab.html(html);
if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && typeof html !== 'string') {
$tab
.empty()
.append($(html).clone(true))
;
}
else {
module.debug('Updating HTML', tabPath, html);
tab.innerHTML = html;
if(evaluateScripts) {
module.debug('Updating HTML and evaluating inline scripts', tabPath, html);
$tab.html(html);
}
else {
module.debug('Updating HTML', tabPath, html);
tab.innerHTML = html;
}
}
}
},
@ -467,7 +475,17 @@ $.fn.tab = function(parameters) {
}
settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent);
settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
if(settings.cacheType != 'response') {
if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && $tab.children().length > 0) {
setTimeout(function() {
let
$clone = $tab.children().clone(true)
;
$clone = $clone.not('script');
module.cache.add(fullTabPath, $clone);
}, 0);
}
else {
module.cache.add(fullTabPath, $tab.html());
}
},

Loading…
Cancel
Save