diff --git a/cards/templates/cards/base.html b/cards/templates/cards/base.html index d844823..98ae92b 100644 --- a/cards/templates/cards/base.html +++ b/cards/templates/cards/base.html @@ -201,17 +201,17 @@ // Match paths like /cards/preview/123/ optionally with trailing slash var m = path.match(/\/cards\/preview\/(\d+)\/?$/); if(m){ - var root = document.getElementById('modal-root'); + var root = document.getElementById('modal-root'); // If server already rendered a modal fragment into #modal-root, do nothing. - if(root && root.innerHTML && root.innerHTML.trim().length > 0) return; - var url = window.location.pathname + window.location.search; - fetch(url, {credentials: 'same-origin'}) - .then(function(r){ if(!r.ok) throw new Error('fetch failed'); return r.text(); }) - .then(function(html){ - var root = document.getElementById('modal-root'); - if(root){ root.innerHTML = html; } - }).catch(function(){ /* ignore */ }); - } + if(root && root.innerHTML && root.innerHTML.trim().length > 0) return; + var url = window.location.pathname + window.location.search; + fetch(url, {credentials: 'same-origin'}) + .then(function(r){ if(!r.ok) throw new Error('fetch failed'); return r.text(); }) + .then(function(html){ + var root = document.getElementById('modal-root'); + if(root){ root.innerHTML = html; } + }).catch(function(){ /* ignore */ }); + } }catch(e){ /* ignore */ } } if(document.readyState === 'loading') document.addEventListener('DOMContentLoaded', tryOpenPreviewFromUrl);