knockout “if binding” not working
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When debugging with Chrome, I can see CoverPrices has 9 elements. The foreach loop actually works well and the table looks correct with the first span being bound to Item1 correctly. However, the if binding does not work and both images are displayed. Yet, all the elements in Item2 have the true value, so only the first image should show up. <!-- ko foreach: CoverPrices --> <tr> <td> <span data-bind="text: Item1"></span> </td> <!-- ko foreach: Item2 --> <td> <img src="~/Images/yes.png" alt="oui" data-bind="if: $data" /> <img src="~/Images/no