Knockout Error .NET您无法多次将绑定应用于同一元素

时间:2013-10-10 17:33:58

标签: c# knockout.js ascx

我遇到一个令我疯狂的问题......

我有以下.ascx,我试图在窗口中显示:注意代码在窗口外工作,但我将其与其他代码集成。

这是.ascx

<div id="modal-location" class="modal">
    <div class="modal-contents">
        <h1>Enter your location and select a theatre for showtimes</h1>

        <div class="modal-form">
            <label class="results-for">
                <div class="label">Results for </div>
                <div>
                    <input type="text" placeholder="Zip or City">
                    <button><span class="icon-magnify-glass">&nbsp;</span></button>
                </div>
            </label>
        </div>

        <div class="faded-rule"></div>

        <ul class="results modal-scroll" data-bind="foreach: theatreData">
            <li>
                <div class="distance">
                    <div class="mileage" data-bind="text: DistanceMiles"></div> 
                    <div>miles away</div>
                </div>
                <div class="theatre-info">
                    <div class="theater-name">

                    <a data-bind="attr: { href: ''}"><span class="theater-link" data-bind="text: TheatreName" /></a> 

                    </div>
                    <div class="theatre-address" data-bind="text: Address1"></div>
                    <div class="theatre-address" data-bind="text: Address2"></div>
                    <div>
                        <span class="theatre-address" data-bind="text: City + ', '"></span>
                        <span class="theatre-address" data-bind="text: State + ' '"></span> 
                        <span class="theater-address" data-bind="text: PostalCode"></span> 
                    </div>
                    <div class="theatre-phone" data-bind="text: PhoneNumber"></div>
                    <button>My Theatre</button>
                </div>
            </li>
        </ul>
    </div>
</div>

<script>



    var a = {};
    a.theatreList = <%= Newtonsoft.Json.JsonConvert.SerializeObject(TheatreList) %> ; 
    $(document).ready(function () {

        ko.applyBindings(new theatreSel.TheatreModel(a.theatreList));

    });
</script>

这是我的js

(function (window) {

    var $ = window.jQuery;
        console = window.console,       
        Regal = window.Regal;
        theatreData = window.theatreData;

    // declare viewmodel constructors in standard fashion
    function TheatreModel(tl) {
        var self = this;

        self.theatreData = ko.observableArray(tl || []);         

    }


    var theatres = {};
    // declare the module exports     
    theatres.TheatreModel = TheatreModel;

    window.theatreSel = theatres;

})(window)

我一直收到错误...未捕获的异常您无法多次将绑定应用于同一元素。我尝试了一些早期问题的建议,但是ko.cleanNode([0])没有用。

0 个答案:

没有答案