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: