Why does this Javascript not work in squiffy but will in a js editor

0 votes
191 views
asked May 19 in Authoring by Rockenden

Hi,

Why does the button execute in a js editor but not in squiffy?

codescreenshot

Many thanks,

1 Answer

+1 vote
answered May 24 by Alex (486 points)

It seems the script tag is messing up parsing the Squiffy file for some reason.

But you don't need to use script tags - you can run JavaScript by indenting it at the top of a passage or section.

For example, here's how you display your button and bind some JavaScript to it:

    $(document).on("click", "#enter-name", function () {
        alert('ok...');
    });

<button id="enter-name">Enter name</button>

To see this working, go here: http://docs.textadventures.co.uk/squiffy/scratchpad/?gistid=0b04d3378e7f93341e39&filename=gistfile1.txt

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...