Extjs subpage calling parent page elements

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.