Howdy, Stranger!

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

Snowman: $(document).ready() equivalent when passage is rendered

I want to manipulate the DOM based on a condition stored in story.state, however I'm having trouble finding the right point to do it.
	$(document).on("ready", function() {
		$('.message').show();
	});

This doesn't work, presumably because the HTML is injected after the page has finished loading. The only way I can do it so far is with a set timeout.

I've also seen this,
	$(document).on("showpassage:after", function() {
		$('.message').show();
	});

but that seems to trigger before the message div has loaded too.

Comments

  • If you'd like the handler to be in a single passage, you can write
    <%
    $(function() {
      $('.message').show();
    });
    %>
    

    But showpassage:after does fire after the passage has been displayed -- see the source code. It may be there that there's another cause why your event handler isn't firing when you expect it to.
Sign In or Register to comment.