I am developing an application that needs to dynamically generate HTML based on certain values. I have the following code where I want the dynamic HTML to go:
<div data-bind="html: extraHTML"></div>
I have an object setup within my javascript file that contains assorted blocks of HTML code that will be chosen once the application has been started. For example one of the object contains the following:
{ type: 'Int', html: '<input style=\'margin: 0\'type=\'number\' min=\'0\' data-bind=\'value: selectedExtra, valueUpdate: \'input\'\' />' }
When I run the application I don't get any errors and the HTML is bound correctly however, when I insert a value into the input field the observable 'selectedExtra' does not update. When I replace the div tag containing the "html" binding with the following:
<input style="margin: 0" type="number" min="0" data-bind="value: selectedExtra, valueUpdate: 'input'">
The observable updates just fine doing this. What I am wondering is if there is anyway to dynamically assign a "value" binding within an "html" binding and have the value actually update. Perhaps there is another solution that I have missed?
Any help would be greatly appreciated, thanks!
Update
I have created a jsfiddle to demonstrate the problem here.