I got the following dom-binding:
object Modals {
val modals = Var[Modal](null)
def show(modal: Modal) = modals.value = modal
def hide(modal: Modal) = modals.value = null
@dom
def apply() = {
if (modals.bind != null) {
<!-- Some static HTMLElements -->
... This is called twice ...
}
}
}
Although the show-Method is only called once (I have double checked it with a debug output), the elements are rendered twice and so I get the error message that the HTMLElements cannot be inserted into DOM twice.
What is the best way to find out, why the binding is recalculated twice? I have no idea how to debug this... For me it only depends on one Var and this is only changed once...
Printing stack trace may help track the source, for example you can place following piece of code under the
.bindstatementnew RuntimeException("...").getStackTrace.take(10).map(println)Also, good old
printlnafter.bindstatements (especially if you have more than one) helps to understand what's happening.