ExtJS를 처음 사용합니다. 응용 프로그램에서 탭 기능을 사용하고 사용자 정의하려고합니다.자바 스크립트의 범위를 벗어난 ExtJS 함수 호출
매개 변수가 이고 JavaScript는 Javascript Scope의 ExtJs 범위에 있습니다. 지금은 오류없이 매개 변수를 전달하지 않고 함수를 호출 할 수 있습니다. 코드에서 언급 한 매개 변수를 전달하여 동일한 함수를 호출 할 때 함수에서 값을 가져 오지 못하므로 다음 오류가 발생합니다.
Uncaught TypeError: Cannot call method 'indexOf' of null
이 기능은 tabpanel에 새 탭을 추가해야합니다.
ExtJS 범위에서 매개 변수를 전달하여 동일한 함수를 호출하면 탭이 성공적으로 추가됩니다. 그러나 함수가 자바 스크립트 범위에서 매개 변수를 전달하여 호출 될 때가 아닙니다. 이 문제를 이해하고 해결하도록 도와주세요.
Ext.onReady(function() {
var currentItem;
var tabs = Ext.widget('tabpanel', {
launch: function() {
_myAppGlobal = this;
},
renderTo: 'tabs',
resizeTabs: true,
enableTabScroll: true,
width: 850,
defaults: {
autoScroll: true,
bodyPadding: 10
}],
plugins: Ext.create('Ext.ux.TabCloseMenu', {
extraItemsTail: [
'-',
{
text: 'Closable',
checked: true,
hideOnClick: true,
handler: function (item) {
currentItem.tab.setClosable(item.checked);
}
},
'-',
{
text: 'Enabled',
checked: true,
hideOnClick: true,
handler: function(item) {
currentItem.tab.setDisabled(!item.checked);
}
}
],
listeners: {
aftermenu: function() {
currentItem = null;
},
beforemenu: function (menu, item) {
menu.child('[text="Closable"]').setChecked(item.closable);
menu.child('[text="Enabled"]').setChecked(!item.tab.isDisabled());
currentItem = item;
}
}
})
});
function addTab_inside(closeable, tabtitle, targetUrl) {
tabs.add({
title: tabtitle,
iconCls: 'tabs',
autoLoad: {url: targetUrl, callback: this.initSearch, scope: this},
closable: closeable,
autoScroll: true,
nocache: true,
discardUrl: false
}).show();
}
});
function addTab_Outside(){
addTab_inside(true, 'Test', 'test.php');
}
addTab_Outside 함수는 이벤트 기반이며 xClick에 onClick이라는 요소가 호출됩니다.
fyi ExtJS 범위 또는 JavaScript 범위와 같은 것이 없습니다. – dbrin
@dbrin ExtJS 범위의 내용을 확인할 수있는 몇 가지 기사를 확인했습니다. [링크 1] (http://aboutfrontend.com/extjs/javascript-scope-and-extjs-scope/), [링크 2] (http://www.sencha.com/forum/showthread.php?58384- solved-call-extjs-function-a-href)를 호출합니다. 내 질문을 편집했습니다. 이 문제를 확인하고 도움을 청하십시오. – Vinay