Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Sample code for using the click event in snowman

$
0
0
So I am trying to save the name of the player using snowman. I am very familiar with JavaScript and jQuery.
Give me your **your** __name__ : <input id="playerName" type="text" /> <input id="enterName" type="button" value="enter" />

My initial impulse was to bind #enterName with the .click() event, and then use jQuery to get the value from playerName. This failed. I have read through a number answers here, and tried the best I could to implement a working solution, but I haven't have any success.

I ran the output created from the published html page through the debugger. Then I found that it renders like this:
</script><tw-passagedata pid="1" name="start" tags="" position="0,1">
<%
s.name = "baba";
alert(s.name);
%>

Welcome to St. Amore's Academy!

[[Continue]]?

Give me your **your** __name__ : <input id="playerName" type="text" /> <input id="enterName" type="button" onclick="window.S.alert("#enterName");" value="enter" />


</tw-passagedata>

Clearly the JavaScript code will be broken because the html lacks the elements with then names "playerName" and "enterName". Based on the rendered markup, it seems that the tw-passagedata will then be rendered at a future point.

My question is how exactly am I supposed to interact with the future markup so that I can access the text field and the onclick event for the button? Seeing a code sample would be probably the best.

Thanks in advance!

Viewing all articles
Browse latest Browse all 1844

Trending Articles