Reputation: 5970
Is there a way to bind dynamically to an object in knockout such as this:
<label data-bind="attr:{for:$data.name}, text:$data.prettyName"></label>
<!-- ko if:$data.isTextBox-->
<input data-bind="attr:{id:$data.name,value:$parent.currentDocument().values[$data.name]}" type="text"></input>
<!-- /ko -->
Or is there any other way to handle k/v binding? values is defined as {} and as the overall type changes values[$data.name] is created.
Upvotes: 1
Views: 357
Reputation: 29693
value
should be binded without attr
<input data-bind="attr:{id:$data.name}, value:$parent.currentDocument().values[$data.name]" type="text"></input>
Upvotes: 1