Stop data binding event in click

I have a checkbox that causes validation in a text box, as well as data binding to the viewmodel.

Here is my fiddle .

<input id="checkbox1" type="checkbox" data-bind="checked: viewitems">Checkbox</input> 

I want the checkbox not to be attached to data when the click event returns a false value.

Is there any way to do this?

Thanks in advance.

+4
source share
1 answer

Can you not just set the value of your observable in the click method?

 $('#checkbox1').click(function () { if (!$('#textbox1').valid()) { viewitems(false) alert("Please enter value"); return; } else { viewitems(true) } }); 
+1
source

All Articles