Use inline binding when relationships between parents and children exist in the binding section, such as ul and li.
Use comment syntax to bind to the container if the bind section does not have a parent-child relationship.
In your example, you use the first block of code because you are not trying to associate it with a child structure. All you want to do is just bind your client data to the div, you do not need to create the parent div and foreach through the clients and add another div inside the parent div. This is more than you want.
Good use of oil free binding
<section> <p data-bind="text: customer.name"></p> <p data-bind="text: customer.orderDate"></p> </section>
However, if you have an ordered list , you should use your own binding , because that makes sense.
Native
<ol data-bind="foreach: customer"> <li data-bind="text: customer.name"></li> </ol>
Containerless
<ol> <li data-bind="text: customer.name"></li> </ol>
The second example looks silly. You add more complexity to something that doesn't have to be complicated.
David East Jun 12 '13 at 15:19 2013-06-12 15:19
source share