-
-
Save motyar/bcd3b11f0e771873cd5d726d98fe7ee0 to your computer and use it in GitHub Desktop.
A simple example that dynamically adds slides to a Reveal.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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