I have a dialog which is used to create 2 sets of data which are switched using a radio button at the top. Depending on the selected value, some fields are removed from the UI (i.e. Admin User and Normal Users).
However, when I try and bind the form to the original serialised data, some items don’t exist so I get binding errors. However, I expect this, as the dialog will have some fields hidden and I don’t want some fields to bind just by way of the data not being in the serialised model. Is there a way to ensure that rather than throwing a binding error, the data item simply silently fails?
I’m using KnockoutJS 1.2.1
You could probably use the
ifbinding which essentially does what you want. It simply doesn’t render what’s within the if binding.Here are the docs: http://knockoutjs.com/documentation/if-binding.html