In RP Niemeyer\'s article Knockout.js Performance Gotcha #3 - All Bindings Fire Together, an approach to building a dropdown list is provided:
Yes, that is definitely an issue. I will have to update the post. IE will strip comments from inside the select.
Here is an issue that we saw on github that is similar: https://github.com/SteveSanderson/knockout/issues/578
One solution is to use Michael Best's repeat
binding: https://github.com/mbest/knockout-repeat.
One of the things that it allows you to do is repeat a single element multiple times with a different context. So, in that case it would act similar to the containerless syntax, just without the comments.
Sample with repeat: http://jsfiddle.net/rniemeyer/QjVNX/
You can also choose to use the other technique from the article (isolatedOptions
), unless you need more control over your option elements.