Sorry for this lengthy question. I am new to knockout.js.
My business case: I have a panel with two checkboxes(Yes/No) inside a foreach loop. For some group of items, when one item is selected with 'Yes' checkbox , I need to uncheck 'Yes' checkbox for other items in the group and select the 'No' checkbox for those items.
- I am using checked event which is bound to observable array (Yes/No in separate observable arrays).
- Items are grouped together by an attribute.(My business case)
- One Observable array will hold the 'Yes' selected items.
- Another observable array will hold 'No' selected items.
- I have a subscribed method to the 'Yes' observable array.
- Inside that I have the logic to remove items in the group who already has 'Yes' selected from this observable array.
The subscribe function is called when user 'checks' the checkbox and is also called when the observable array is changed inside the subscribe method due to my logic which I have explained above in Point 6.
Problem: Things seem to work fine which I am able to see through debugging through developer tools, but when the logic to remove the already selected value is executed it is not reflected in the UI. Checkboxes still shows 'Yes' as selected for more than 1 item in the group.
Ex: When One of the item's 'Yes'checkbox is selected in the group the other items 'Yes'checkbox in the group must be unselected. This seems to reflect in the variable values but the UI shows the other items still have 'Yes' checkbox as selected.
My Observable array which holds the 'Yes' selected items still shows the correct values in it(in console) but the UI shows more than 1 item has 'Yes' selected.
Please let me know the issue here.
Aucun commentaire:
Enregistrer un commentaire