0

Not sure what's up with this, but the visible property does not seem to work using foreach.

This works (displays Testing 2 only):

<tbody data-bind="foreach: people">
    <tr>
        <td data-bind="text: $data.firstName"></td>
        <td data-bind="text: $data.lastName"></td>
         <td>
        <div data-bind="visible: false">
           Testing 1
        </div>
         <div data-bind="visible: true">
           Testing 2
        </div>
         </td>
    </tr>

This doesn't work (displays both): //boolean values = makeFalse is false and makeTrue is true

<tbody data-bind="foreach: people">
    <tr>
        <td data-bind="text: $data.firstName"></td>
        <td data-bind="text: $data.lastName"></td>
         <td>
        <div data-bind="visible: $data.makeFalse">
           Testing 1
        </div>
         <div data-bind="visible: $data.makeTrue">
           Testing 2
        </div>
         </td>
    </tr>

Any ideas on how to get it to work?

4

1 回答 1

2

我记得被困在这样的事情上。尝试使用 ()。

<div data-bind="visible: $data.makeFalse()"></div>
<div data-bind="visible: $data.makeTrue()"></div>
于 2013-07-10T20:03:02.097 回答