Knockoutjs: Hide Image When Emty Or Null
I'm trying to implement knockoutjs for the first time in a web page. I stumbled into the following problem, but maybe it is also a case of 'best practices'. I have a product page,
Solution 1:
I've worked out a jsFiddle example regarding your questions: http://jsfiddle.net/XAXKZ/5
You've made some mistakes:
- isActive and IsActive mixed up. JavaScript is still case sensitive. And you need to show it as a function:
data-bind="visible: !IsActive()"
- You can also test other variables this way, without the need to add dedicated functions for it:
data-bind="visible:productOverview.Image() == '' || productOverview.Image() == null"
Solution 2:
You should call the observable like this :
<img src="../../images/notactive_icon.gif" data-bind="visible: productOverview.isActive() " />
It's because isActive is a function so it's never null
Post a Comment for "Knockoutjs: Hide Image When Emty Or Null"