knockout data-bind on dynamically generated elements

If you add this element on the fly after you have bound your viewmodel it will not be in the viewmodel and won’t update. You can do one of two things.

  1. Add the element to the DOM and re-bind it by calling ko.applyBindings(); again
  2. OR add the list to the DOM from the beginning and leave the options collection in your viewmodel empty. Knockout won’t render it until you add elements to options on the fly later.

Leave a Comment