i am pretty new to knockoutjs. I have a set of buttons clubbed under different fieldsets. I have bound the buttons to a single observable to enable or disable the buttons. On clicking a button under a fieldset i want only the set of buttons under that fieldset to be disabled. How do i do it through knockout.
I have created a fiddle for this here trying to explain my problem
Thanks.
<div data-bind="foreach: items">
<fieldset>
<ul data-bind="foreach: $data.item">
<li class="list">
<input type="button" data-bind="value: $data.title, enable: $root.isEnabled, click: $root.buttonClicked"
/>
</li>
</ul>
</fieldset>
Have a look at this working fiddle. Hope it will helps you for what you want to achieve.
Below is the html code, notice here we used disable binding to disable buttons.
<ul data-bind="foreach: Buttons">
<li class="list">
<input type="button" data-bind="value: Title,
click: $root.SetSelectedButton,
disable: $root.SelectedButton() === $data"
/>
</li>
</ul>
EDIT
Sorry i missed your point in which you mentioned that you want to disable set of buttons. Here is the another fiddle which is the next version of the previous fiddle. In this fiddle you can enable or disable the set of buttons :
Updated working fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With