How to find out, why a DOM binding is rendered twice

97 Views Asked by At

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...

1

There are 1 best solutions below

0
Roman On

Printing stack trace may help track the source, for example you can place following piece of code under the .bind statement

new RuntimeException("...").getStackTrace.take(10).map(println)

Also, good old println after .bind statements (especially if you have more than one) helps to understand what's happening.