I’ve got an issue with knockoutjs. I may be doing this completly wrong, but I have an observableArray being set with ajax data and it’s working fine.
However when I run the ajax again, I remove all items (observableArray.removeAll) which works fine, but then the view just doubles up – I have all the previous items + all the new items.
My html/view looks like the following (I am using the containerless control flow in the 1.3 beta)
<div class="rowCollection">
<!-- ko foreach: products -->
<!-- ko foreach: Stock -->
<!-- ko if: !DefaultSKU -->
<div class="row">
<div class="cell product" data-bind="html: $parent.ProductName"></div>
<div class="cell level">
<input type="text" data-bind="valueUpdate: 'afterkeydown', bind_stockLevel: $data.StockLevel" />
</div>
<div class="cell infinite"><input type="checkbox" data-bind="checked: StockInfinite" tabindex="-1" /></div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</div>
If I remove all of the child foreach statements it works fine – so seems to be a nesting problem?
Any ideas? Or is this a bug? Been trying to find anything relating to it, but not luck yet.
Thanks
Dan
There is currently some type of bug related to either having consecutive containerless bindings or having containerless bindings as the root node in some cases. I have not had a chance to fully research it yet, but did look into a simliar report on KO forums recently.
The workaround for the time being is to add another element in there like: http://jsfiddle.net/rniemeyer/HPSbY/1/
I will make sure that I update this response, with any additional details or fix plans.