TabView和关闭按钮问题

发布于 2024-07-27 18:23:16 字数 2625 浏览 8 评论 0原文

我尝试做与 Davs Rants 示例相同的事情: http://blog.davglass.com/files/yui/tab3/

但是我必须忘记一些东西......

我有这个错误:

未找到节点”代码:“8 [中断 这个错误] this._tabParent.removeChild( tab.get(ELEMENT) );

这是我的代码:

function onGenePubmedSubmit() {

var contentCur = document.getElementById("curatedquery");
var contentValue = contentCur.value;

// New tabView widget
var tabView = new YAHOO.widget.TabView('tvcontainer');

// Define label and content
var labelText = nameReq + '<span class="close">X</span>';
var tabcontainer = idReq;
var content = "<div id="+tabcontainer+"></div>";

// Add new tab - work well !
if (labelText && content)
{
tabView.addTab( new YAHOO.widget.Tab({
                label:labelText,
                content:content,
                id: 'pubmedView',
                active:true }));
                }

// Define DataTable myPubmedListTable Columns
var myColumnDefsPubmed = [
    {key:"pmid", label:"PMID", sortable:true},
    {key:"articletitle", label:"Article Title", sortable:true},
    {key:"abstract", label:"Abstract", sortable:true},
    {key:"authorlist", label:"Authorlist", sortable:true},
    {key:"medline", label:"Medline", sortable:true}
    ];

// Define DataSource
var myDataSourcePubmed = new YAHOO.util.DataSource("qct-list-article.html");
myDataSourcePubmed.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSourcePubmed.connXhrMode = "queueRequests";
myDataSourcePubmed.responseSchema = {
  resultsList: "articleItemList",
  fields: ["pmid","articletitle","abstract","authorlist","medline"]
  };

// myPubmedListTable config
var oConfigsPubmed = {
    initialRequest: '?term='+ contentValue,
    selectionMode: "single"
    };

// Create new DataTable - myPubmedListTable
var myPubmedListTable = new YAHOO.widget.DataTable(idReq, myColumnDefsPubmed, myDataSourcePubmed,oConfigsPubmed);

// Show myPubmedListTable
myPubmedListTable.onShow();

// Remove tab on tabView ----------- this part don't work---------- !          
YAHOO.util.Event.on(tabView.getElementsByClassName('close')[0], 'click', function(ev) {
YAHOO.util.Event.stopEvent(ev);
             //  some test - but don't work !               
             //  tabView.set('activeTab', tabView.get('tabs')[0]);
             //  tabView.set('activeIndex', 1);
             //  tabView.removeTab(tabView.get("activeTab"));
tabView.removeTab(tabView);
                      });
}

有人可以帮助我吗?

我缺少什么?

谢谢。

I try to do the same thing as Davs Rants Example :
http://blog.davglass.com/files/yui/tab3/

But I must forget something...

I have this error :

Node was not found" code: "8 [Break on
this error]
this._tabParent.removeChild(
tab.get(ELEMENT) );

Here my code :

function onGenePubmedSubmit() {

var contentCur = document.getElementById("curatedquery");
var contentValue = contentCur.value;

// New tabView widget
var tabView = new YAHOO.widget.TabView('tvcontainer');

// Define label and content
var labelText = nameReq + '<span class="close">X</span>';
var tabcontainer = idReq;
var content = "<div id="+tabcontainer+"></div>";

// Add new tab - work well !
if (labelText && content)
{
tabView.addTab( new YAHOO.widget.Tab({
                label:labelText,
                content:content,
                id: 'pubmedView',
                active:true }));
                }

// Define DataTable myPubmedListTable Columns
var myColumnDefsPubmed = [
    {key:"pmid", label:"PMID", sortable:true},
    {key:"articletitle", label:"Article Title", sortable:true},
    {key:"abstract", label:"Abstract", sortable:true},
    {key:"authorlist", label:"Authorlist", sortable:true},
    {key:"medline", label:"Medline", sortable:true}
    ];

// Define DataSource
var myDataSourcePubmed = new YAHOO.util.DataSource("qct-list-article.html");
myDataSourcePubmed.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSourcePubmed.connXhrMode = "queueRequests";
myDataSourcePubmed.responseSchema = {
  resultsList: "articleItemList",
  fields: ["pmid","articletitle","abstract","authorlist","medline"]
  };

// myPubmedListTable config
var oConfigsPubmed = {
    initialRequest: '?term='+ contentValue,
    selectionMode: "single"
    };

// Create new DataTable - myPubmedListTable
var myPubmedListTable = new YAHOO.widget.DataTable(idReq, myColumnDefsPubmed, myDataSourcePubmed,oConfigsPubmed);

// Show myPubmedListTable
myPubmedListTable.onShow();

// Remove tab on tabView ----------- this part don't work---------- !          
YAHOO.util.Event.on(tabView.getElementsByClassName('close')[0], 'click', function(ev) {
YAHOO.util.Event.stopEvent(ev);
             //  some test - but don't work !               
             //  tabView.set('activeTab', tabView.get('tabs')[0]);
             //  tabView.set('activeIndex', 1);
             //  tabView.removeTab(tabView.get("activeTab"));
tabView.removeTab(tabView);
                      });
}

Can someone help me ?

What I missing?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

亣腦蒛氧 2024-08-03 18:23:16

这里似乎发生了一些奇怪的事情; 我看不到 idReq 定义在哪里,并且 content 定义了两次。

我想知道像

这样奇怪的内容是否会导致它。

There seem to be some strange things afoot here; I can't see where idReq is defined, and content is defined twice.

I wonder if content being something weird like <div id=></div> could cause it.

冧九 2024-08-03 18:23:16

我做了一些更改:现在只有一个内容(第一个内容现在是 contentCur)。

但同样的错误。

在我的代码中:
idReq 被定义为全局(没关系 - 我可以添加选项卡),我有类似的东西:

<div id=901></div>

我认为,问题出在(但我错过了什么?):
YAHOO.util.Event.on(tabView.getElementsByClassName('close')[0], '点击', function(ev) {
...

谢谢。

I made some changes : now only one content (firt content is now contentCur).

But same error.

In my code :
idReq is define as global (it's ok - I can add tabs), I have something like :

<div id=901></div>

I think, the problem is in (but what I missing?):
YAHOO.util.Event.on(tabView.getElementsByClassName('close')[0], 'click', function(ev) {
...

Thank you.

情泪▽动烟 2024-08-03 18:23:16

我找到了一个可行的解决方案,并添加了一个分页器。

function onGenePubmedSubmit() {

var contentCur = document.getElementById("curatedquery");
var contentCurValue = contentCur.value;

var tabView = new YAHOO.widget.TabView('tvcontainer');

var labelText = nameReq + '<span class="close">X</span>';
var tabcontainer = idReq;
var content = "<div id="+tabcontainer+"></div>";

if (labelText && content)
{
 var ctabView = new YAHOO.widget.Tab({
 label:labelText,
 content:content,
 id: 'pubmedView'+idReq,
 active:true });
}

YAHOO.util.Event.on(ctabView.getElementsByClassName('close')[0], 'click',
function(ev) {
YAHOO.util.Event.stopEvent(ev);

// Verify if Tab to remove is curently the activ Tab
if (tabView.get('activeTab')==ctabView)
{
 // We activate the first Tab
 tabView.set('activeTab', tabView.get('tabs')[0]);
}
 // If Tab to remove not activ Tab
else if (tabView.get('activeTab')!=ctabView)
{
 // We set the index of the Tab that is currently active in the TabView.
 tabView.set('activeIndex',tabView.get('activeIndex')); 
}

tabView.removeTab(ctabView);
});

// Verify if tab exist (or not)
var tabExist = document.getElementById('pubmedView'+idReq);
if (tabExist == null)
{
 tabView.addTab(ctabView);
}
else
{
 alert("Tab already exist")  ;
}

// Define DataTable myPubmedListTable Columns
var myColumnDefsPubmed = [
{key:"pmid", label:"PMID", sortable:true},
{key:"articletitle", label:"Article Title", sortable:true},
{key:"abstract", label:"Abstract", sortable:true},
{key:"authorlist", label:"Authorlist", sortable:true},
{key:"medline", label:"Medline", sortable:true}
];

// Define DataSource
var myDataSourcePubmed = new YAHOO.util.DataSource("qct-list-article.html");
myDataSourcePubmed.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSourcePubmed.connXhrMode = "queueRequests";
myDataSourcePubmed.responseSchema = {
resultsList: "articleItemList",
fields: ["pmid","articletitle","abstract","authorlist","medline"],
metaFields: {
totalRecords: "totalArticleRecords" // Access to value in the server response
}
};

// Add Paginator
var pubmedPaginator = new YAHOO.widget.Paginator({
rowsPerPage: 5,
template: YAHOO.widget.Paginator.TEMPLATE_ROWS_PER_PAGE,
rowsPerPageOptions: [5,10,15,20]
});

var myRequestPubmedBuilder = function(oState,oSelf)
{
oState = oState || {pagination:null, sortedBy:null};

var retstart = (oState.pagination != null) ? oState.pagination.recordOffset : 0;
var retmax = (oState.pagination != null) ? oState.pagination.rowsPerPage : 5;

return '?term=' + contentCurValue + '&retstart=' + retstart + '&retmax=' + retmax;
}

// myPubmedListTable config
var oConfigsPubmed = {
initialRequest: '?term=' + contentCurValue + '&retstart=0' + '&retmax=5',
dynamicData: true, // Enables dynamic server-driven data
selectionMode: "single",
paginator: pubmedPaginator,
generateRequest : myRequestPubmedBuilder,
caption : "Pubmed articles for this query : " //+ contentCountPubmed
};

// Create new DataTable - myPubmedListTable
if (tabExist == null)
 {
 var myPubmedListTable = new YAHOO.widget.DataTable(idReq, myColumnDefsPubmed, myDataSourcePubmed,oConfigsPubmed);


 myPubmedListTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
 if (oPayload == undefined)
 { oPayload = {}; }

 oPayload.totalRecords = oResponse.meta.totalRecords;
 return oPayload;
 }

 // Show myPubmedListTable
 myPubmedListTable.onShow();
 }
}

I found a solution that works, and I added a paginator.

function onGenePubmedSubmit() {

var contentCur = document.getElementById("curatedquery");
var contentCurValue = contentCur.value;

var tabView = new YAHOO.widget.TabView('tvcontainer');

var labelText = nameReq + '<span class="close">X</span>';
var tabcontainer = idReq;
var content = "<div id="+tabcontainer+"></div>";

if (labelText && content)
{
 var ctabView = new YAHOO.widget.Tab({
 label:labelText,
 content:content,
 id: 'pubmedView'+idReq,
 active:true });
}

YAHOO.util.Event.on(ctabView.getElementsByClassName('close')[0], 'click',
function(ev) {
YAHOO.util.Event.stopEvent(ev);

// Verify if Tab to remove is curently the activ Tab
if (tabView.get('activeTab')==ctabView)
{
 // We activate the first Tab
 tabView.set('activeTab', tabView.get('tabs')[0]);
}
 // If Tab to remove not activ Tab
else if (tabView.get('activeTab')!=ctabView)
{
 // We set the index of the Tab that is currently active in the TabView.
 tabView.set('activeIndex',tabView.get('activeIndex')); 
}

tabView.removeTab(ctabView);
});

// Verify if tab exist (or not)
var tabExist = document.getElementById('pubmedView'+idReq);
if (tabExist == null)
{
 tabView.addTab(ctabView);
}
else
{
 alert("Tab already exist")  ;
}

// Define DataTable myPubmedListTable Columns
var myColumnDefsPubmed = [
{key:"pmid", label:"PMID", sortable:true},
{key:"articletitle", label:"Article Title", sortable:true},
{key:"abstract", label:"Abstract", sortable:true},
{key:"authorlist", label:"Authorlist", sortable:true},
{key:"medline", label:"Medline", sortable:true}
];

// Define DataSource
var myDataSourcePubmed = new YAHOO.util.DataSource("qct-list-article.html");
myDataSourcePubmed.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSourcePubmed.connXhrMode = "queueRequests";
myDataSourcePubmed.responseSchema = {
resultsList: "articleItemList",
fields: ["pmid","articletitle","abstract","authorlist","medline"],
metaFields: {
totalRecords: "totalArticleRecords" // Access to value in the server response
}
};

// Add Paginator
var pubmedPaginator = new YAHOO.widget.Paginator({
rowsPerPage: 5,
template: YAHOO.widget.Paginator.TEMPLATE_ROWS_PER_PAGE,
rowsPerPageOptions: [5,10,15,20]
});

var myRequestPubmedBuilder = function(oState,oSelf)
{
oState = oState || {pagination:null, sortedBy:null};

var retstart = (oState.pagination != null) ? oState.pagination.recordOffset : 0;
var retmax = (oState.pagination != null) ? oState.pagination.rowsPerPage : 5;

return '?term=' + contentCurValue + '&retstart=' + retstart + '&retmax=' + retmax;
}

// myPubmedListTable config
var oConfigsPubmed = {
initialRequest: '?term=' + contentCurValue + '&retstart=0' + '&retmax=5',
dynamicData: true, // Enables dynamic server-driven data
selectionMode: "single",
paginator: pubmedPaginator,
generateRequest : myRequestPubmedBuilder,
caption : "Pubmed articles for this query : " //+ contentCountPubmed
};

// Create new DataTable - myPubmedListTable
if (tabExist == null)
 {
 var myPubmedListTable = new YAHOO.widget.DataTable(idReq, myColumnDefsPubmed, myDataSourcePubmed,oConfigsPubmed);


 myPubmedListTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
 if (oPayload == undefined)
 { oPayload = {}; }

 oPayload.totalRecords = oResponse.meta.totalRecords;
 return oPayload;
 }

 // Show myPubmedListTable
 myPubmedListTable.onShow();
 }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文