我有一个从Backbone操作打开的窗口:
...
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);
},
...
它调用popupSearchView.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>
我最初打电话来创建一个包含jQuery-UI选项卡区域的窗口。这一切似乎都运行正常,除了当我尝试调用addTab函数,在jQuery-UI选项卡窗口中创建另一个选项卡时,它只是创建一个新窗口。我希望它只是附加到现有的“tab”div,然后刷新选项卡以显示新选项卡。有没有办法可以确保第二次调用displayData会将html附加到现有窗口以添加第二个标签?
我希望有。