Skip to content

Commit

Permalink
Merge pull request #95 from virusman/turbolinks-css
Browse files Browse the repository at this point in the history
Turbolinks support: disable CSS temporarily instead of removing head altogether
  • Loading branch information
rstacruz committed Apr 6, 2013
2 parents 121f247 + 36d376e commit d9fd157
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/better_errors/templates/main.erb
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,18 @@
host app.
%>
<script>
if (window.Turbolinks) document.head.innerHTML = "";
if (window.Turbolinks) {
for(var i=0; i < document.styleSheets.length; i++) {
if(document.styleSheets[i].href)
document.styleSheets[i].disabled = true;
}
document.addEventListener("page:restore", function restoreCSS(e) {
for(var i=0; i < document.styleSheets.length; i++) {
document.styleSheets[i].disabled = false;
}
document.removeEventListener("page:restore", restoreCSS, false);
});
}
</script>

<div class='top'>
Expand Down

0 comments on commit d9fd157

Please sign in to comment.