Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sugarcube 2: Display/Jump to passage via javascript?

Hey there!

I would like to achieve the following via script tag: If a video is ended I would like to jump to a certain passage. But I can't figure out how to call the History.display-Api? (can't find something in window.SugarCube.* which lets me call this)
<<script>>
$( document ).ready(function() {

/* Video ended event */
	document.getElementById('dystopia_connect').addEventListener('ended',myHandler,false);
    
function myHandler(e) {
        if(!e) { e = window.event; }

/* JUMP TO / DISPLAY PASSAGE "Headquarter" */

    }
}); /* eo ready */
<</script>>

Thanks in advance!

Best regards,
Matthias

Comments

  • edited June 2015
    1. Drop the call to ready(), if the story format is running, then you're already past that point.

    2. window.SugarCube is for debugging purposes only.

    3. Try this: (state is the instance of History)
    <<script>>
    $("#dystopia_connect").on("ended", function (evt) {
    	state.display("Headquarter", this);
    });
    <</script>>
    
Sign In or Register to comment.