简体   繁体   English

KnockoutJS`with`绑定和IE8

[英]KnockoutJS `with` binding and IE8

For some reason my code is generating the error below in IE8, but not in any of the normal browsers. 出于某种原因,我的代码在IE8中生成了以下错误,但在任何普通浏览器中都没有。

SCRIPT5022: Unable to parse bindings.
Message: TypeError: 'logoSrc' is undefined;
Bindings value: 'attr': { 'src': logoSrc } 

I confirmed that the logoSrc property is indeed defined, even in IE8, right before binding, but still it fails. 我确认logoSrc属性确实已定义,即使在IE8中,在绑定之前,但仍然失败。 And disabling the binding to logoSrc just causes the next binding in line to fail. 禁用与logoSrc的绑定只会导致下一个绑定失败。

The html is below. html如下。 I know I've used a with binding before, so I'm pretty sure that's not the problem, and the html seems to be properly closed. 我知道我之前使用过带绑定,所以我很确定这不是问题,并且html似乎已经正确关闭了。

<div data-bind="visible: mode() === 'print'" class="container-fluid">
    <!-- ko with: printVm -->
    <div class="row-fluid">
        <div class="span12">
            <div class="page-header">
                <div class="pull-right" style="width:140px;height:60px;overflow:hidden;">
                    <img data-bind="'attr': { 'src': logoSrc }" src="" />
                </div>
                <h2>Invoice Statement - <span data-bind="text: itemZeroClientName"></span></h2>
            </div>
            <strong>Invoice number:</strong> <span data-bind="text: invoiceId"></span>
            <strong>Invoice date:</strong> <span data-bind="text: userInfo().invoiceDateDisplay"></span>
            <strong>Client number:</strong> <span data-bind="text: itemZeroClientId">22365</span>
            <hr />
        </div>
    </div>
    <div class="row-fluid">
        <div class="span6 cr-tablet6 cr-phone6">
            <h4>Billed by <span data-bind="text: companyNameDisplay"></span></h4>
            <span data-bind="html: companyInfo"></span>
        </div>
        <div class="span6 cr-tablet6 cr-phone6">
            <h4>Billed to</h4>
            <span data-bind="html: clientInfoDisplay"></span>
        </div>
    </div>

    <div class="row-fluid">
        <div class="span12">
            <hr />
            <table id="printInvoiceTable" class="table">
                <thead>
                <tr>
                    <th class="date">Date</th>
                    <th class="name">Provider</th>
                    <th class="code">Proc Code</th>
                    <th class="location">Location</th>
                    <th class="time">Hours</th>
                    <th class="units">Units</th>
                    <th class="charge">Charges</th>
                </tr>
                </thead>
                <tbody data-bind="foreach: items">
                    <tr>
                        <td data-bind="text: dateDisplay"></td>
                        <td data-bind="text: orgName"></td>
                        <td data-bind="text: procedureCodeString"></td>
                        <td data-bind="text: location"></td>
                        <td class="formatted-number" data-bind="text: timeWorkedHrs"></td>
                        <td class="formatted-number" data-bind="text: (unitsOfService() || 0).toFixed(2)"></td>
                        <td class="formatted-currency" data-bind="text: (clientCharges() || 0).toFixed(2)"></td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td class="formatted-number" data-bind="text: totalWorkedHours"></td>
                        <td class="formatted-number" data-bind="text: totalUnitsOfService"></td>
                        <td class="formatted-currency" data-bind="text: totalClientRate"></td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
    <!-- /ko -->
</div>

如上所述,似乎问题是IE8删除注释(以及在某些条件下的虚拟绑定)并已在淘汰论坛上报告

I have had issues using with and jquery file upload in IE8. 我在IE8中使用with和jquery文件上传时遇到了问题。 I also had issues with comments and was able to fix it by escaping the comment condition. 我也有评论问题,并能够通过逃避评论条件来解决它。 the knockout webpage mentions this warning. 淘汰赛网页提到了这个警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM