#2627·knockout

Update from 3.4.1 to 3.5.3 broke value binding on dynamically-created select element

Author: NilotavianoCreated May 20, 2026Updated Jul 31, 2026

I updated from 3.4.1 to 3.5.3 and encountered a strange bug when binding to a dynamically-created select element.

Here's a sanitized snippet of how the element was created and bound to:

const selectElement = document.createElement("select");
selectElement.className = 'selectClassName';
selectElement.innerHTML = $('#optionsTemplate').html(); // template containing the list of options
container.appendChild(selectElement);

ko.applyBindingsToNode(selectElement, {
    value: viewModel.selectedOption,
    disable: viewModel.editDisabled,
    attr: { title: viewModel.title },
    css: { isDefaulted: viewModel.isDefaulted },
    style: { display: viewModel.cssDisplay }
})

The value binding would not work at all.

I fixed it by using the options binding, instead of setting the options via innerHTML on the select element (which to be fair was a strange choice by whoever wrote it), alongside valueAllowUnset: true.