Extjs4 self-study manual-ext basic methods, attributes (onready, define, create)

Source: Internet
Author: User

1. Ext. onready

Note: Statement blocks in onready are loaded in the context of the page before being executed.

Example:

 <  Html  > 
< Head >
< Title > Index </ Title >
< Link Href = "Http://www.cnblogs.com/Scripts/ext-4.0.7-gpl/ext-4.0.7-gpl/resources/css/ext-all.css"
REL = "Stylesheet" Type = "Text/CSS" />
< Script SRC = "Http://www.cnblogs.com/Scripts/ext-4.0.7-gpl/ext-4.0.7-gpl/ext-all-dev.js" Type = "Text/JavaScript" > </ Script >
< Script SRC = "Http://www.cnblogs.com/Scripts/App/Data/books.js" Type = "Text/JavaScript" > </ Script >
< Script Type = "Text/JavaScript" >
Ext. onready ( Function (){
// Obtain the page element. The element ID is "onready"
VaR Input = Ext. Get ( " Onready " );
Ext. msg. Alert ( " Hide control content " , Input. Dom. value );
});
</ Script >
</ Head >
< Body >
< Div ID = "Ext4-Panel" >
< Input Type = "Hidden" Value = "The page has been loaded" ID = "Onready" />
</ Div >
</ Body >
</ Html >

Execution result:

IfCodeIf the segment is not put in Ext. onready, an error is returned:

 

2. Ext. Define

Description: Creates a class that can inherit other classes or be inherited.

Example 1:

     < Script  Type  = "Text/JavaScript"  >  
Ext. onready ( Function (){
// Creates a class named textclass with two attributes: A and B.
Ext. Define ( ' Textclass ' ,{
A: ' A ' ,
B: ' B '
});
// Instantiation class
VaR Textclass = New Textclass ();
// Output attribute name
Ext. msg. Alert ( ' Class attributes ' , Textclass. + " " + Textclass. B );
});
</ Script >

Execution result:

Example 2:

     <  Script  Type  = "Text/JavaScript"  >  
Ext. onready ( Function (){
// Creates a class named textclass with two attributes: A and B.
Ext. Define ( ' Textclass ' ,{
A: ' A ' ,
B: ' B '
});
// Create a class that inherits textclass
Ext. Define ( " Textclass2 " ,{
Extend: ' Textclass ' , // Inherit textclass
C: ' C ' // Textclass2 attributes
})
VaR Textclass2 = New Textclass2 ();
Ext. msg. Alert ( " Textclass2 attributes " , Textclass2.a + " " + Textclass2. B + " " + Textclass2.c)
});
</ Script >

Execution result:

 

3. Ext. Create

Description: instantiation class. We recommend that you use the Create method to instantiate the class in extjs4.

     <  Script  Type  = "Text/JavaScript"  >  
Ext. onready ( Function (){
// Creates a class named textclass with two attributes: A and B.
Ext. Define ( ' Textclass ' ,{
A: ' A ' ,
B: ' B '
});

VaR Textclass = Ext. Create ( " Textclass " )

Ext. msg. Alert ( ' Textclass attributes ' , Textclass. + ' ' + Textclass. B)
});
</ Script >

Execution result:

 

 

 

 

 

 

 

 

 

 

 

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.