I have a recursive dom in KnockoutJs:
<ul data-bind="template: { name: 'tree-hierarchy', foreach: someArray }"></ul>
<script id="some-tree" type="text/html">
<li>
<input type="checkbox" data-bind="attr: { id: id, name: name, value: value}, click: someFunc">
</li>
</scrpt>
I want to get the checked element's attributes so I use click functionality to get the data in the fucntion:
someFunc(data: any, event: any) {
//event.target gets me the attributes
}
I get the data I want in event.target, but immedialtly checked becomes unchecked. If click functionality is not there, like this, checked remains:
<input type="checkbox" data-bind="attr: { id: id, name: name, value: value}>
The check remains, but when 'click' functionality calling the function is present, it unchecks immediately. I want it to remain. I dont want to use 'checked: boolValue', functionality of knockout, since it is dynamically created and if there are 10 values in array, there would be 10 checbox inputs, hence having one bool value makes no sense.
I want checkbox to remain checked, after the call to function is completed.
Aucun commentaire:
Enregistrer un commentaire