You need to change your html as follows:
<table> <tr data-bind="visible: showRow"><td>Some Text</td></tr> </table>
And JavaScript as follows:
var ViewModel = function() { var self = this; self.showRow = ko.observable(false); self.toggleVisibility = function() { self.showRow(!self.showRow()); alert('showRow is now ' + self.showRow()); }; }; ko.applyBindings(new ViewModel());
The syntax for setting the value for the observed property is: self.showRow(value);
If you need tags inside tags.
I also modified your script to simplify javascript and follow new code rules regarding "this". See http://jsfiddle.net/FgVxY/4/
photo_tom
source share