@dom
def chart(show: Var[Boolean]) = {
if(show.bind) {
How can I init the canvas with some
@dom
def chart(show: Var[Boolean]) = {
if(show.bind) {
val myCanvas = <canvas id="chartCanvas"><canvas>
myInitializationCode(myCanvas)
myCanvas
} else {
<!-- don't show canvas -->
}
}
You can create a custom SingleMountPoint, and put the initialization code in the overriden mount
method:
val yourCustomMountPoint = new SingleMountPoint[Boolean](show) {
override def mount() = {
super.mount()
// Your custom initialization code
}
override def unmount() = {
// Your custom clean up code
super.unmount()
}
override def set(newValue: Boolean) = {
// Your custom handler when `show` get changed
}
}
// Inject your custom mount point into the rendering process
yourCustomMountPoint.bind