Knockout.js SharePoint 2013淘汰版对我的DOM进行永久性更改

Knockout.js SharePoint 2013淘汰版对我的DOM进行永久性更改,knockout.js,sharepoint-2013,Knockout.js,Sharepoint 2013,我对SharePoint非常陌生,但我有淘汰赛的经验。我已经设置了一个页面,可以运行我所有的代码。我在浏览器中查看页面,一切都很好。当我进入编辑页面时,一切都很好,但当我完成编辑后,我所有的Knockout-foreach绑定都成倍增加,页面上有更多的元素。如果我坐在编辑页面上,一段时间后,击倒绑定将被重新评估,我可以看到新元素被添加到页面中。此外,如果我进入SharePoint Designer并查看页面的代码,所有这些元素现在实际上都在代码中 “我的内容编辑器”Web部件中的代码如下所示:

我对SharePoint非常陌生,但我有淘汰赛的经验。我已经设置了一个页面,可以运行我所有的代码。我在浏览器中查看页面,一切都很好。当我进入编辑页面时,一切都很好,但当我完成编辑后,我所有的Knockout-foreach绑定都成倍增加,页面上有更多的元素。如果我坐在编辑页面上,一段时间后,击倒绑定将被重新评估,我可以看到新元素被添加到页面中。此外,如果我进入SharePoint Designer并查看页面的代码,所有这些元素现在实际上都在代码中

“我的内容编辑器”Web部件中的代码如下所示:

<div id="vcmContainer">
    <div id="contentHead" data-bind="foreach: Processes">
        <div class="column process">
            <div class="header">
                <!-- ko if: $index() > 0 -->
                <div class="divider"></div>
                <!-- /ko -->
                <span data-bind="text: name"></span>
            </div>
        </div>              
    </div>
    <div id="contentBody" data-bind="foreach: Processes">
        <div class="column">
            <div class="contentTypes" data-bind="foreach: contentTypes">
                <div class="contentType">
                    <span data-bind="text: contentType"></span>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/SiteAssets/Scripts/jquery-2.1.1.min.js"></script> 
<script src="/SiteAssets/Scripts/knockout-3.1.0.js"></script> 
<script src="/SiteAssets/Scripts/ko.sp-1.0.min.Ex.js"></script> 
<script src="/SiteAssets/Scripts/script.js"></script>
下面是script.js:

function ViewModel() {
    var self = this;

    self.Processes = ko.observableArray([
        { name: ko.observable("Scheduling Requests"), 
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Test Requirement Documents") },
                { contentType: ko.observable("Flight Test Services Request") },
                { contentType: ko.observable("Schedules") }
          ])
        },
        { name: ko.observable("Planning"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") }
          ])
        },
        { name: ko.observable("Configuration Control"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Airplane Modification"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Test Execution"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Tracking"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Analysis Reporting"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        }
    ]);
}

$(function(){
    var vm = new ViewModel();
    ko.applyBindings(vm);
}); 

我环顾四周,没有发现其他人有类似的情况。事实上,我发现的每一个教程都有击倒设置,并以我习惯的方式使用。我确实找到了一个名为KoSp Knockout for SharePoint的库,它具有特殊的SharePoint绑定,但其他教程似乎没有它也可以使用。任何帮助都将不胜感激。

您能发布您的viewModel吗?还有,你是说如果你进入编辑页面,什么都不做,一段时间后会添加更多的元素吗?是的,在浏览器中,我看着一位编辑,和一位同事谈论这个问题,这时我看到页面重新评估和扩展。我还添加了javascript代码。我想我的问题是因为我将淘汰代码直接放入sharepoint网站。我已经转而制作sharepoint应用程序,情况好多了。但是,如果有人知道,浏览器中的站点编辑器是否应该像这样不断地评估淘汰代码?
function ViewModel() {
    var self = this;

    self.Processes = ko.observableArray([
        { name: ko.observable("Scheduling Requests"), 
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Test Requirement Documents") },
                { contentType: ko.observable("Flight Test Services Request") },
                { contentType: ko.observable("Schedules") }
          ])
        },
        { name: ko.observable("Planning"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") }
          ])
        },
        { name: ko.observable("Configuration Control"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Airplane Modification"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Test Execution"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Tracking"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Data Analysis Methods") },
                { contentType: ko.observable("First Flight Readiness Review") },
                { contentType: ko.observable("Test Point Tables") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        },
        { name: ko.observable("Analysis Reporting"),
          contentTypes: ko.observableArray([
                { contentType: ko.observable("Plans") },
                { contentType: ko.observable("Safety Review Boards") }
          ])
        }
    ]);
}

$(function(){
    var vm = new ViewModel();
    ko.applyBindings(vm);
});