KnockoutJS: "My HTML node has disappeared"

This is probably the one question I get asked the most about KnockoutJS. Why is my 'some random html node' not apearing on my page? And this is often followed up with a code sample similar to: <!-- ko foreach: myList --> <th data-bind="text: label"> <button>*</button> </th> <!-- /ko --> In this case the button node isn't being shown in the rendered html. Now the reason for this is that when you use the data-bind="text: label" attribute on a node, knockout…

Read More

Knockout JSON Viewer Update

Knockout JSON Viewer Update

I've added a couple of additional features to my jsonViewer, Subscriber count and embedded stylesheet. The green number now shows how many subscribers the observable has, which is good. However, there are a couple of caveats. Firstly, it's important to note, that if a child observable has a subscriber then its parents subscriber count will increment by one. Also if the observable is bound to a DOM object it will increment the subscriber count. Its not just the number of subscribing functions. In addition to this I've embedded the stylesheet in the javascript. As this is debugging tool I wanted…

Read More

Knockout JSON Viewer

Knockout JSON Viewer

Would you know it. Starting another blog. Just wanted to introduce my jsonViewer for knockout. The aim is to make it a little easier to debug your view models. As it can be really difficult to get an idea of what's going on behind the scenes. It shows you the view model as it currently is and the number of times each of the observables (and none) properties have changed. Check it out on github or the examples. Its not finished yet, things to come are: showing the number of subscribers, allowing the view model tree to be expanded/collapsed…

Read More