Javascript 主干打开.window引用该.w

Javascript 主干打开.window引用该.w,javascript,jquery,jquery-ui,backbone.js,window.open,Javascript,Jquery,Jquery Ui,Backbone.js,Window.open,我有一个从主干网操作中打开的窗口: ... displayData: function() { var that = this; var id = that.passDataObj.id; var htmlToWrite = that.AAComment(); if (that.windowToWriteInCreated == false) { that.windowToWriteInCreated = true; that.wi

我有一个从主干网操作中打开的窗口:

...
displayData: function() {
    var that = this;
    var id = that.passDataObj.id;
    var htmlToWrite = that.AAComment();
    if (that.windowToWriteInCreated == false) {
        that.windowToWriteInCreated = true;
        that.windowToWriteIn = window.open("popupSearchView.html", "", "menubar=no, resizable=yes, scrollbars=yes, status=no");
       $(that.windowToWriteIn.document.getElementById('tabs')).html("<ul>" +
                                                                        "<li>" +
                                                                            "<a href='#tabs-" + id + "'>" + id + "</a>" +
                                                                            "<span class='ui-icon ui-icon-close' role='presentation'>RemoveTab</span>" +
                                                                        "</li>" +
                                                                    "</ul>" +
                                                                    "<div id='tabs-" + id + "'>" +
                                                                        htmlToWrite +
                                                                    "</div>");

        that.windowToWriteIn.addEventListener('load', that.windowToWriteIn.createTabs(), true);
    } else {
       $(that.windowToWriteIn.document.getElementById('tabs')).append("<ul>" +
                                                                        "<li>" +
                                                                            "<a href='#tabs-" + id + "'>" + id + "</a>" +
                                                                            "<span class='ui-icon ui-icon-close' role='presentation'>RemoveTab</span>" +
                                                                        "</li>" +
                                                                    "</ul>" +
                                                                    "<div id='tabs-" + id + "'>" +
                                                                        htmlToWrite +
                                                                    "</div>");

        that.windowToWriteIn.addEventListener('load', that.windowToWriteIn.addTab(), true);
},
...
。。。
displayData:function(){
var=这个;
var id=that.passDataObj.id;
var htmlToWrite=that.AAComment();
if(that.windowtowriteincremated==false){
that.windowtowriteincremated=true;
that.windowToWriteIn=window.open(“popusearchview.html”,“menubar=no,resizeable=yes,scrollbars=yes,status=no”);
$(that.windowToWriteIn.document.getElementById('tabs')).html(
    )+ “
  • ”+ "" + “移除选项卡”+ “
  • ”+ “
”+ "" + htmlToWrite+ ""); that.windowToWriteIn.addEventListener('load',that.windowToWriteIn.createTabs(),true); }否则{ $(即.windowToWriteIn.document.getElementById('tabs')).append(
    )+ “
  • ”+ "" + “移除选项卡”+ “
  • ”+ “
”+ "" + htmlToWrite+ ""); that.windowToWriteIn.addEventListener('load',that.windowToWriteIn.addTab(),true); }, ...
它调用具有以下代码的PopusSearchView.html的html代码:

...
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="./jquery-ui.1.11.2.min.redmond.css" />
<script src="./jquery-1.10.2.min.js"></script>
<script src="./jquery-ui.js"></script>
<script>
    function createTabs() {
        $('#tabs').tabs();
    }

    function addTab() {
        $('#tabs').tabs("refresh");
    }
</script>
</head>
<body>
    <div id='tabs'>
    </div>
</body>
。。。
函数createTabs(){
$(“#tabs”).tabs();
}
函数addTab(){
$('#制表符')。制表符(“刷新”);
}
最初,我打电话是为了创建一个包含jQuery UI选项卡区域的窗口。这一切似乎都很好,只是当我尝试调用addTab函数时,要在jQuery UI选项卡窗口中创建另一个选项卡,它只需创建一个新窗口。我希望它只需附加到现有的“tab”div,然后刷新选项卡即可o显示新选项卡。是否有办法确保第二次调用displayData时,会将html附加到现有窗口以添加第二个选项卡


我希望有。

代码太难阅读了。你应该使用一个模板引擎。请尝试更好地格式化它,并共享一个@T J-我确实有模板,即“var htmlToWrite=that.AAComment();”语句正在从主干视图的初始化中的预定义模板调用。除此之外,我不相信JSFIDLE可以显示该语句,因此我无法对代码“不可读”的问题提供太多帮助。在主干代码的另一部分调用displayData。这可能会有所帮助。