scala.js - Fetching data from a webpage when a button is pressed in scala js -


i want fetch data text boxes i've in form on web page in scala js. i've tried using html'` onclick event :

<button id="submit" type="button" onclick="tutorialapp().fun()">submit</button> 

and i've created function in tutorialapp object :

object tutorialapp extends jsapp {  @jsexport def main(): unit = {    .....  }  def fun():unit = {  println("button clicked") }     

but showing error tutorialapp().fun() not function. wrong code ?

as alternative, might want register onclick handlers in code:

import org.scalajs.dom  def main(): unit = {   dom.document.getelementbyid("submit").addeventlistener("click", fun _) } 

the advantage not need export fun , compile time name safety (i.e. if rename fun, compiler tell if forgot rename somewhere).


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -