Skip to content

Accessing API with multiple embedded presentations #3122

@jaybonthius

Description

@jaybonthius

In the documentation for API Methods, it says

If you're working with a single presentation instance the API can be accessed via the global Reveal object.

But what if I'm working with multiple embedded presentations? I've tried a few of different things, none of which work.

On my page, I have a few embedded presentations which I initialize in a for loop. Then I try to detect slidechanged events with .on('slidechanged', ...). This correctly detects slide changes on each presentation, but then console.log(rev.getCurrentSlide()) outputs the current slide of the last presentation on the page (regardless of which presentation had a slidechanged event).

var elms = document.getElementsByClassName( 'reveal' );
for ( var i = 0; i < elms.length; i++ ) {
    var rev = new Reveal( elms[ i ], {
        // config options
    } );

    rev.initialize();
    
    rev.on( 'slidechanged', event => { 
        console.log(rev.getCurrentSlide());
    });
}

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions