PDA

View Full Version : How to pass arguments to init function?



neophp
4 Aug 2009, 6:50 PM
Now, I use onDocumentReady and want to show the same tree five times in a webpage.
In a page, threre are five DIV tags(ex : treeBox1, treeBox2, ... etc).
So, I want to control one tree panel with different el which change the el name at five times.
Please Help..

---------------------------------------
function makeFolderMailboxTree() {
Ext.BLANK_IMAGE_URL="/js/extjs/resources/images/default/s.gif";
var makeFolderMailbox = function() {
return {
init : function() {
onepanel = new Ext.tree.TreePanel({
el:'treeBox1',
loader: new Ext.tree.TreeLoader()
});
// set the root node
var oneroot = new Ext.tree.AsyncTreeNode({
allowDrop:false,
id:'ROOT',
children: <?=$json_date?>
});
onepanel.setRootNode(oneroot);
onepanel.render();
onepanel.on('click', doClick);
}
};
}();
Ext.EventManager.onDocumentReady(makeFolderMailbox.init, makeFolderMailbox, true);
}
makeFolderMailboxTreeilbo

ecsun
4 Aug 2009, 7:09 PM
the arguments will passed to the function,one,two,three ....,as more as you need.

neophp
4 Aug 2009, 8:07 PM
I am not understand what you said.

Is there any examples?


makeFolderMailboxTree(1);
makeFolderMailboxTree(2);
makeFolderMailboxTree(3);

When i call the function, can i use the arguments 1,2,3 in init function?

Thanks for your help!!.