jQuery, my function is return a FUNCTION and not an integer?
Posted
by
AnApprentice
on Stack Overflow
See other posts from Stack Overflow
or by AnApprentice
Published on 2010-12-31T21:42:57Z
Indexed on
2010/12/31
21:54 UTC
Read the original article
Hit count: 270
jQuery
|knockoutjs
Hello, i have the following func:
viewModel.unreadCount = ko.dependentObservable(function() {
var unreadCount = 0;
for (var i = 0; i x< xxxxxxxxxxxx.length; i++) {
if (xxxxxx == false) {
unreadCount++;
}
}
return unreadCount;
}, viewModel);
When I use this in knockout JS, I can't do a simple if (viewModel.unreadCount()==0), like this:
<div data-bind="visible: viewModel.unreadCount()==0">
It turns out because when I run:
<p>${ (typeof viewModel.unreadCount) }</p>
I get "function"
Any ideas why that is and how I can get it to return an INT so I can do an if statement?
Thanks
© Stack Overflow or respective owner