Created
February 3, 2015 16:14
-
-
Save tonyfast/77f34f5867df98ca9418 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>Single Horizontal Slide</section> | |
<section id="blank"></section><!-- Blank slug --> | |
</div> | |
</div> | |
<script> | |
;(function(){ | |
Reveal.initialize(); | |
//slide deck wrapper | |
deck = $('#blank').parent(); | |
// a blank is initialized and stored as a variable | |
wrap = $('#blank').clone() | |
.attr('id',null) | |
.prop('outerHTML'); | |
// remove the blank | |
$('#blank').remove(); | |
// add some slides | |
newslide(1); | |
newslide(2); | |
newslide('Woop,woop'); | |
})(); | |
function newslide(i){ | |
// wrap the new content in the blank | |
$('<em>Slide added'+i+'</em>').appendTo(deck) | |
.wrap( wrap ); | |
}; | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HOW TO ADD DYNAMIC CONTENTS INSIDE SLIDES?