scala - How to access 'this' element from event handler passed into scalatags? -
i'm trying access text of current (this
) element within event handler created scalatags. here tried:
val onchange = {(e: htmlelement) => number() = e.textcontent.toint }: js.thisfunction input(`type`:="number", onchange := onchange).render
when debug above code, nothing being passed onchange
function. specifically, if put function body: js.dynamic.global.alert(json.stringify(e))
, prints {}
. also, error e.textcontent
null. how pass in javascript this
element?
i got clarification on scala.js gitter, , turns out can access element within closure so:
val inputelem = input(`type`:="number").render inputelem.onchange = {(e: event) => number() = inputelem.value.toint }
Comments
Post a Comment