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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -