Skip to content

Instantly share code, notes, and snippets.

@motyar
Forked from tonyfast/index.html
Last active June 11, 2020 06:09
Show Gist options
  • Save motyar/bcd3b11f0e771873cd5d726d98fe7ee0 to your computer and use it in GitHub Desktop.
Save motyar/bcd3b11f0e771873cd5d726d98fe7ee0 to your computer and use it in GitHub Desktop.
A simple example that dynamically adds slides to a Reveal.js
<head>
<link rel="stylesheet" href="//cdn.jsdelivr.net/g/reveal.js(css/reveal.min.css)">
<script src="//cdn.jsdelivr.net/g/reveal.js,zepto"></script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-markdown data-separator-vertical="^===" data-separator="^---">
<script type="text/template" id="md"></script>
</section>
</div>
</div>
<script>
;(function(){
Reveal.initialize();
//slide deck wrapper
deck = $('#md').parent();
// a blank is initialized and stored as a variable
wrap = $('#md').clone()
.attr('id',null)
.prop('outerHTML');
// remove the blank
$('#md').remove();
// add some slides
newslide(1);
newslide(2);
newslide('Woop,woop');
})();
function newslide(i){
// wrap the new content in the blank
$('# Slide added'+i).appendTo(deck)
.wrap( wrap );
Reveal.sync();
};
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment