Based on the fact that your <a>
element example includes both a data-passage property and a tag onclick event handler, you seem to be trying to have two things happen when the end-user selects that link:
- a normal Passage Transition to the Next Passage.
- the execution of the
send_multiple_choice()
JavaScript function.
…and not necessarily in that order.
One issue is that the SugarCube engine uses a ‘click’ event handle on the element to execute the code that does the Passage Transaction, and I doubt that the code that attaches that engine related event handle to the element in question knows how to chain any event handler already attached to the ‘click’ event. So it is likely that your tag based ‘click’ event handler is being replaced by the engine’s.
If you do want your send_multiple_choice()
function to be executed before a Passage Transition to Next Passage occurs then simply use a standard <<link>>
macro call like the following…
<<link "Steak" "Next Passage">>
<<set $multipleChoiceSelection to 'Steak'>>
<<run send_multiple_choice()>>
<</link>>