1
votes

I'm trying to show one div when a property is true and another if the property is false.

example: http://jsfiddle.net/FgVxY/151/

Using knockout I with the visible binding -> data-bind="visible: testTrue", works fine... But trying -> data-bind="visible: testTrue== false" doesn't...

<div class='eg'>   
<input type='checkbox' data-bind="checked: testTrue" />
<br />
<div data-bind="visible: testTrue">true</div>
<div data-bind="visible: testTrue == false">false</div>    

Does anyone have a sollution for this?

1
The "visible" binding in the documentation has an example for this exact thing. See towards the end of the article. - bzlm
showRow is a function, you need showRow() == false: jsfiddle.net/FgVxY/149 In the previous case, knockout just unwraps it for you automatically. - Matt Burland
@bzlm I know, which is why I didn't understand why my sollution didn't work. - Zaphod
@MattBurland Thank you!! that seems to work, I'll do some more testing, but I think that cracked it.. - Zaphod
@Zaphod In the section on "Using functions and expressions to control element visibility" (which you are doing), you can see the need for parentheses to let you use parameters in code. The beginning of the article only uses view model properties as parameters. - bzlm

1 Answers

0
votes

I found the sollution.. I was kind of looking at the worng place, so thanks to those who tried to help, but my question was unpresise.

We use Kendo ui and hence knockout js. I thought the issue was with knockout visible binding, and I still believe there is issues with that, but the sollution was with kendo.

Kendo has an invisible binding, which is the opposite to the visible binding. Using invisible lets you test for 'false' rather than 'true'.