Is there a Binding.scala way to append dom elements?

189 Views Asked by At

I would like to append a Binding node to another Binding node without re-rendering the parent node. Is there a specific way how Binding.scala would handle this?

1

There are 1 best solutions below

0
kahliburke On

Bindings can be nested and composed, so in general it's not something you need to think about. A Binding[T] represents an object that is dynamically bound and will be recomputed when any upstream Binding's value changes.

Your question is a bit ambiguous so you may want to clarify or add a code example, but there is nothing extra you need to do to accomplish your goal. Look at the examples and also this section of the README:

https://github.com/ThoughtWorksInc/Binding.scala/blob/11.0.x/README.md#precise-data-binding

Also, I made a quick example of what I'm talking about here:

https://scalafiddle.io/sf/XZgtwHM/1

If you open up your browser console, you'll see that the method that renders out the parent node is only called the first time, but if you click the button more child elements will be appended without the parent node being affected. Inspect the HTML and pay attention to the id of the parent div, it is set up to increment the ID each time it gets rendered, and the id remains as "parent_1" the whole time.