Knockout.js 敲除外部模板值重置

Knockout.js 敲除外部模板值重置,knockout.js,knockout-templating,Knockout.js,Knockout Templating,我使用敲除外部模板 但是如何从外部模板中清除新绑定的值和文本。 我的html代码是这样的 HTML <ul data-bind="template: { name: 'RegistrationForm.html' }"></ul> <div data-bind="click:Add"></div> 但不工作,我只需要刷新模板。 谢谢是否可以在此基础上重新制作一个示例。让我猜RegistrationForm.html将有针对元素的可见绑

我使用敲除外部模板

但是如何从外部模板中清除新绑定的值和文本。 我的html代码是这样的

HTML

<ul data-bind="template: { name: 'RegistrationForm.html' }"></ul>
 <div data-bind="click:Add"></div>    
但不工作,我只需要刷新模板。
谢谢

是否可以在此基础上重新制作一个示例。让我猜
RegistrationForm.html
将有针对元素的可见绑定,在
add
函数上只需像
self.name(“”)一样清除即可
etclet me try for a fiddle.@supercool很难添加fiddle,但我的代码是这样的,请阅读所有注释行。然后您就可以解开了。谢谢
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Templates</title>
        <style>
            .clear {
                clear: both;
            }
        </style>
        <script type="text/javascript" src="lib/jquery-1.11.2.min.js"></script>
        <script type="text/javascript" src="lib/knockout-3.3.0.js"></script>
        <script type="text/javascript" src="lib/koExternalTemplateEngine_all.js"></script>
        <script>
                    $(function(){
                    function pop1(data)
                    {
                    this.a = ko.obeservable(data.a || '');
                            this.b = ko.obeservable(data.b || '');
                    }
                    function pop2(data)
                    {
                    this.c = ko.obeservable(data.c || '');
                            this.d = ko.obeservable(data.d || '');
                    }
                    Viewmodel = function(){
                    self = this;
                            self.obj = new Object();
                            self.name = {
                            id:1
                                    name:'test'
                            };
                            self.types = [
                            {
                            id:1
                                    name:'test'
                            },
                            {
                            id:2
                                    name:'test2'
                            }

                            ];
                            self.whichPopup = fucntion(){
                    switch (name()){
                    case '1':
                            //Load Template for this option
                            //This wil b a user form with some value will bind when on laod
                            var data {}; // data with a and b
                            self.obj = new pop1(data);
                            break;
                            case '2':
                            //Load Template for this option
                            var data {}; // data with c and d
                            self.obj = new pop1(data);
                            break;
                    }
                    };
                    };
                    }); </script>
    </head>
    <body>
        <div class="Temp">
            <div class="temp1">  
                <div data-bind="template:{name : 'Template1.html'}"></div>  
            </div>
            <div class="clear"></div>
            <div class="temp2">                 
                <div data-bind="template:{name : 'Template2.html'}"></div>              
            </div>  
            <div class="clear"></div>
            <select class="submission_type"
                    data-bind="options: types,
                                   optionsText : 'name',                               
                                   value: name,
                                   optionsCaption:'---Select---'
                    ">
            </select>
            <div data-bind="template:{name : whichPopup}"></div>
            <!--  This part working -->
            <!--
             Table here
             i need to add multiple entried here,
            so will add users here

             1- Select type
             2- Tempalte will opened in a popup
             3- Save to,then dispaly to the grid
            -->


            <!--
              1- Selcted option type that i hav already added before for to add same type but diffrent user
              2- popup1 will opened
              3- but it have the values that i have first time added
              4- if it was text box only then i can clear but it have some text binding to a div too
            -->
        </div>  

    </body>
</html>
infuser.defaults.ajax.cache = false