2009-07-10 64 views
0

我嘗試做同樣的事情DAVS叫嚷例如: http://blog.davglass.com/files/yui/tab3/TabView的和關閉按鈕的問題

但我必須忘掉的東西...

我有這樣的錯誤:

節點未找到「code:」8 [Break on this error] 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); 
         }); 
} 

有人能幫助我嗎?

我缺少什麼?

謝謝。

回答

0

我找到了解決辦法這是有效的,我添加了一個分頁器。

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(); 
} 
} 
0

在這裏似乎有一些奇怪的事情發生;我看不到idReq在哪裏定義,並且內容被定義了兩次。

我不知道是否像<div id=></div>奇怪的內容可能會導致它。

0

我做了一些改變:現在只有一個內容(firt內容現在是contentCur)。

但同樣的錯誤。

在我的代碼: idReq是定義爲全局的(這是確定 - 我可以添加標籤),我有這樣的:

<div id=901></div> 

我認爲,這個問題是在(但我缺少的是什麼?) : YAHOO.util.Event.on(tabView.getElementsByClassName( '關閉')[0], '點擊',功能(EV){ ...

謝謝