2013-07-24 2 views
0

Tabview :YUI 3 나는이 방법에 의해 tabview를 만들었습니다 액세스

var tabview; 
var Y = YUI({ insertBefore: 'my_css' }); 
Y.use('tabview', function (Y) { 
    tabview = new Y.TabView({ 
    children: [{ 
     label: 'Suche', 
     content: "<div id=\"tab1\"> </div>" 
    }, { 
     label: 'Objekt-Liste', 
     content: "<div id=\"tab2\"> </div>" 
    }, { 
     label: 'Objekt-Detail', 
     content: "<div id=\"tab3\"> </div>" 
    }] 
}); 

tabview.item(1).disable().on('selectedChange', function() { 
    if (boolTab1) { 
     return true; 
    } else { 
     return false; 
    } 
}); 

tabview.item(2).disable().on('selectedChange', function() { 
    if (boolTab2) { 
     return true; 
    } else { 
     return false; 
    } 
}); 
tabview.render('#tabs'); 
}); 

지금은 외부에서 내 tabview 개체에 액세스하고 싶습니다. 예 : 로드시이 함수는 다음과 같이 호출됩니다.

function init() { 

tabview.deselectAll(); 
tabview.selectChild(0); 
this.name = ""; 
this.value = ""; 
boolTab1 = false; 
boolTab2 = false; 
tabview.item(1).disable(); 
tabview.item(2).disable(); 
requestSuche(this); 
} 

따라서 FF로 완벽하게 작동합니다. 그러나 테스트 한 다른 모든 브라우저는 init() 함수의 tabview 객체에 대해 알지 못합니다. 흥미로운 점; 파이어 폭스에서 그것은 또한 상단에있는 'var tabview'를 제거 할 때 작동합니다. 내 다른 js 함수에서 내 탭보기에 올바르게 액세스하려면 어떻게해야합니까?

답변

0

좋아요, 문제는 init() 함수가 내 tabview가 생성되기 전에 호출 된 본문의 onload 함수라는 것입니다. init() 함수를 내 tabview codeblock으로 이동하면 문제가 해결됩니다.

관련 문제