JsFiddle: http://jsfiddle.net/fPsK6/2/
Why visible binding doesn’t work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because the values of the
IsDefaultproperties are strings, which always evaluate totrue. The only string which does not evaluate totrueis the empty string.Here’s an updated working fiddle.
In that version I’ve simply removed the quotes around the numbers (so they are actually numbers, not strings). The number
1evaluates totrue, and the number0evaluates tofalse. You could of course use literal boolean values instead of numbers (or any other values that evaluate totrueandfalseappropriately).Update (see comments)
Since your data comes from the server and you can’t change it, you can convert the string to a number in the
data-bindattribute value:Note that you need to call
IsDefaultas a function, rather than just giving a reference to the function. Also note the use of the unary plus operator, which converts a string to a number.Here’s another updated fiddle.