Skip to content

Update for recent tooling versions - Scala 3 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Step 4: Reacting on User Input
  • Loading branch information
gzm0 authored and OndrejSpanel committed Mar 24, 2024
commit d2adbfeb036400b7cd5b45ff33e7aeedc34821ab
4 changes: 4 additions & 0 deletions scalajs-tutorial-fastopt.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<title>The Scala.js Tutorial</title>
</head>
<body>
<button id="click-me-button" type="button" onclick="addClickedMessage()">
Click me!
</button>

<!-- Include Scala.js compiled code -->
<script type="text/javascript" src="./target/scala-2.13/scala-js-tutorial-fastopt/main.js"></script>
</body>
Expand Down
7 changes: 7 additions & 0 deletions src/main/scala/tutorial/webapp/TutorialApp.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tutorial.webapp

import scala.scalajs.js.annotation.JSExportTopLevel

import org.scalajs.dom
import org.scalajs.dom.document

Expand All @@ -13,4 +15,9 @@ object TutorialApp {
parNode.textContent = text
targetNode.appendChild(parNode)
}

@JSExportTopLevel("addClickedMessage")
def addClickedMessage(): Unit = {
appendPar(document.body, "You clicked the button!")
}
}