snoopy_15
snoopy_15

Reputation: 1313

Knockout "if" and "ifnot" doesn't work

I'm using knockout and have this code

self.array = ko.observableArray([]);

HTML

<!--ko if: array().length > 0-->
<tr>
<td>Some text</td>
</tr>
<!--/ko-->
<!--ko ifnot: array().length > 0-->
<tr>
<td>Some other text</td>
</tr>
<!--/ko-->

I'm using some other knockout statements and they works but this doesn't work, and I can't figure out why. Can somebody help me please?

Upvotes: 0

Views: 299

Answers (1)

dfperry
dfperry

Reputation: 2258

It seems that using virtual elements inside a table requires the use of a wrapping <tbody> element.

See my fiddle: http://jsfiddle.net/yq9v7d0g/2/

Once I added the <tbody> element, everything worked fine. This used to be a problem in Internet Explorer, but seems to be an issue again.

Upvotes: 3

Related Questions