ScalaJS Tutorial Step 4 Problem

Dear all,

I am following the ScalaJS tutorial:

I don’t get the specified output at Step 4. That is, clicking the button doesn’t add the specified paragraph. For the reference, I am including the relevant HTML at the P.S. here. (I am using ~fastOptJS so SBT automatically builds the project upon update.) Anyone knows what’s going wrong?



<!DOCTYPE html>
    <meta charset="UTF-8">
    <title>The Scala.js Tutorial</title>
    <!-- Include Scala.js compiled code -->
    <button id="click-me-button" type="button" onclick="addClickedMessage">
      Click me!
    <script type="text/javascript" src="./target/scala-2.11/scala-js-tutorial-fastopt.js"></script>

Could it be that you need to add parentheses here: onclick="addClickedMessage()"?

Truly so. Well spotted. :slight_smile: