ScalaTags is a small XML/HTML construction library for Scala.
I'm trying to access the text of the current (this) element from within an event handler created with scalatags. Here is what I tried:
val onChange = {(e: HTMLElement) =>
number() = e.textContent.toInt
}: js.ThisFunction
input(`type`:="number", onchange := onChange).render
When I debug the above code, nothing is being passed into the onChange function. Specifically, if I put this into the function body: js.Dynamic.global.alert(JSON.stringify(e)), it prints {}. Also, I get an error that e.textContent is null. How do I get it to pass in the javascript this element?
Source: (StackOverflow)
The title tag is not working as expected with the ScalaTags library.
import scalatags.Text.all._
title("My Awesome Website")
How can I get this to work?
Help docs/tutorials are conveniently missing the ubiquitous title tag. I hope the dev fixes this..
https://github.com/lihaoyi/scalatags
Not Working as Expected:
If you look at how tags such as link, script, head, html are used the title tag should work the same.
For some reason the dev chose to make this tag ConcreteHtmlTag[Nothing] rather than the former tag's type ConcreteHtmlTag[String]. Its also strange that this tag is in the Tags2 package rather than Tags, it is a commonly used tag after all.
Source: (StackOverflow)