Recently, I have been working on extjs-related projects and found that I really lack a lot of things for JavaScript stuff. So I want to write this article and I hope it will be helpful to you, ^ V ^.
In extjs, tabpanel is often used, while a panel in tabpanel is embedded with a JSP, HTML, and other sub-pages. Sometimes we need
Tabpanel to perform some operations, such as adding a panel for tabpanel. In this case, we need to be able to obtain the tabpanel object of the parent page or the tabpanel object already written on the parent page.
Add a panel to a tabpanel.
The sub-page does not need to be mentioned. Generally, window. Parent. xxx or window. Parent. XXX () is used to obtain the parent page object or method (Note: XXX represents the parent page
Object or method), as shown belowCode(Addtab is a sub-page function, and goto is the function of the parent page ):
1 Function Addtab (URL, proname, proid ){
2 URL = " Projectinfo. jsp? Projectid = " + URL;
3 Window. Parent. Goto (URL, " Project Overview " , Proname, proid, ' 4 ' );
4 };
Sometimes we often use Windows. parent. the Goto () method cannot be obtained. Why? The main issue lies in the scope of a JS. In extjs, the parent page often uses Ext. an onready () method is usually used to put the definition in this method, for example:
1 Ext. onready ( Function (){
2 Function Goto (){
3 Xxxxxxxxxx ....
4 }
5 VaR Centerpanel = Ext. tabpanel ();
6 })
The Goto and centerpanel in this region are in ext. in the onready area, the scope is also in this, not global, so we cannot access it on the sub-page. To access yes, the methods and objects
Put it out of Ext. onready. In this way, for some global methods, the object sub-page is useful, and we set it to global in the parent page for ease of use.