Js utils

Create Js

button.btn.btn_success.apply("click me").addOnClick(Js("alert('clicked')"))

Escape string

val string = """string with 'single' and "double" quotes"""
button.btn.btn_success.apply("click me").addOnClick(Js(s"""alert("${JS.escapeStr(string)}")""")) ++
  button.ms_2.btn.btn_primary.apply("click me").addOnClick(Js(s"""alert('${JS.escapeStr(string)}')"""))

Element by id

d_flex.justify_content_between.apply {
  input.withType("text").withId("id1").withValue("Lorem ipsum dolor sit amet").form_control ++
    button.ms_2.btn.btn_primary.apply("Get input elem").addOnClick(Js(s"""alert('Elem: '+${JS.elementById("id1")})""")).text_nowrap
}

Element value by id

d_flex.justify_content_between.apply {
  input.withType("text").withId("id2").withValue("All work and no play makes Jack a dull boy").form_control ++
    button.ms_2.btn.btn_primary.apply("Get input elem value").addOnClick(Js(s"""alert('Elem: '+${JS.elementValueById("id2")})""")).text_nowrap
}

Copy to clipboard

button.btn.btn_success.apply("Copy UUID").addOnClick(JS.toClipboard(UUID.randomUUID().toString))