I am binding the click event to every list item in a list:
<ul class="modal-subject-list" data-bind="foreach: filteredSubjects">
<li data-bind="click: $parent.pickSubject, css: {alreadyAddedBackground: hasBeenAdded}">
<!-- Lots of code here -->
</li>
</ul>
I want to disable the click: binding if 'hasBeenAdded' resolves to true. I know some messy ways to take care of it:
- Have two list items, one for
if: hasBeenAdded, and the other forif: !hasBeenAdded. This is far from DRY - Handle this check with javascript and leave the view alone - I don't like this because unnecessary markup is being generated for list items that should be essentially disabled.
Is there a way to register a "clickIf" binding?