adding slides to deck after init?

50 views
Skip to first unread message

Greg

unread,
Mar 7, 2012, 4:37:11 AM3/7/12
to dec...@googlegroups.com
Hi, 
what is the best practice to add slides to a deck after the initial call to init?

I would like to add transition slides using d3.js but that currently doesn't work because these new slides are not part of the deck array (when I understand things correctly). 
.append("div").attr("class","slide").attr("id","transition1");

I could just reinitialize using $.deck('.slide'); but I am not sure whether this is good practice considering that I use append multiple times. 

Thanks!


ps: Thanks for the quick fix of the nested elements bug!

Caleb Troughton

unread,
Mar 9, 2012, 8:10:49 AM3/9/12
to dec...@googlegroups.com
I'm not sure why you don't just put this element in the HTML markup.  But assuming you have some good reason for leaving it out...

There is an event in core called deck.beforeInit.  From the docs:

This event fires at the beginning of deck initialization, after the options are set but before the slides array is created. This event makes a good hook for preprocessing extensions looking to modify the deck.

So just do your appending inside $(document).bind('deck.beforeInit', function() { ............. }

And you COULD just keep calling init over and over.  I've written core and all the included plugins such that this could happen without messing anything up.  A node knockout team did this with every keystroke from the user to show a live updating deck as you typed in an editor, and it seemed to work well.  If you're using 3rd party plugins I can't speak to how they're written, if they would withstand multiple inits or not.
Reply all
Reply to author
Forward
0 new messages