Howdy, Stranger!

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

Snowman 2 binding to showpassage:after

Hi folks. I'm trying to execute some javascript after the passage loads. Anyone have an example on how to make this work?

In the source code for story.js, there's this
$.event.trigger('showpassage:after', { passage: passage });
In the Javascript window of the Twine 2 editor, I've tried this (as well as binding to "body" and "html").

$("div").bind('showpassage:after', function(e, passage){
var $element = e.target;
alert("after show passage");
});
Nothing fires. Any ideas?

Comments

  • Use the document object and the on() method (bind() should work, but on() is preferred).  Like so:

    $(document).on("showpassage:after", function (e, passage) {
    alert('after show passage for "' + passage.passage.name + '"');
    });
  • Thanks! Works like a charm.
Sign In or Register to comment.