Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / api / Ext.Base.html
1 <!DOCTYPE html><html><head><title>Ext.Base | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
8
9     req = {
10         liveURL: '.',
11         standAloneMode: true,
12         origDocClass: 'Ext.Base',
13         docClass: 'Ext.Base',
14         docReq: 'Ext.Base',
15         version: '4.0',
16         baseURL: '.',
17         baseDocURL: '.',
18         baseProdURL: '.'
19     };
20
21     clsInfo = {};
22
23
24
25 </script>
26
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32     req.source = 'Base3.html#Ext-Base';
33     clsInfo = {"methods":["callOverridden","getName"],"cfgs":[],"properties":["addStatics","borrow","create","createAlias","implement","override"],"events":[],"subclasses":["Ext.form.action.Action","Ext.slider.Thumb","Ext.env.Browser"]};
34     Ext.onReady(function() {
35         Ext.create('Docs.classPanel');
36     });
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/Base3.html#Ext-Base" target="_blank">Ext.Base</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>The root of all classes created with <a href="Ext.html#define" rel="Ext#define" class="docClass">Ext.define</a>
38 All prototype and static members of this class are inherited by any other class</p>
39 <div class="members"><div class="m-properties"><a name="properties"></a><div class="definedBy">Defined By</div><h3 class="prp p">Properties</h3><div id="property-addStatics" class="member f ni"><a href="Ext.Base.html#property-addStatics" rel="property-addStatics" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-property-addStatics" class="viewSource">view source</a></div><a name="addStatics"></a><a name="property-addStatics"></a><a href="Ext.Base.html#" rel="property-addStatics" class="cls expand">addStatics</a><span> : Function</span></div><div class="description"><div class="short">Add / override static properties of this class.
40
41 Ext.define('My.cool.Class', {
42     ...
43 });
44
45 My.cool.Class.addStatics(...</div><div class="long"><p>Add / override static properties of this class.</p>
46
47 <pre><code>Ext.define('My.cool.Class', {
48     ...
49 });
50
51 My.cool.Class.addStatics({
52     someProperty: 'someValue',      // My.cool.Class.someProperty = 'someValue'
53     method1: function() { ... },    // My.cool.Class.method1 = function() { ... };
54     method2: function() { ... }     // My.cool.Class.method2 = function() { ... };
55 });
56 </code></pre>
57 </div></div></div><div id="property-borrow" class="member ni"><a href="Ext.Base.html#property-borrow" rel="property-borrow" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-property-borrow" class="viewSource">view source</a></div><a name="borrow"></a><a name="property-borrow"></a><a href="Ext.Base.html#" rel="property-borrow" class="cls expand">borrow</a><span> : Function</span></div><div class="description"><div class="short">Borrow another class' members to the prototype of this class.
58
59 Ext.define('Bank', {
60
61 money: '$$$',
62 printMoney: functi...</div><div class="long"><p>Borrow another class' members to the prototype of this class.</p>
63
64 <p>Ext.define('Bank', {</p>
65
66 <pre><code>money: '$$$',
67 printMoney: function() {
68     alert('$$$$$$$');
69 }
70 </code></pre>
71
72 <p>});</p>
73
74 <p>Ext.define('Thief', {</p>
75
76 <pre><code>...
77 </code></pre>
78
79 <p>});</p>
80
81 <p>Thief.borrow(Bank, ['money', 'printMoney']);</p>
82
83 <p>var steve = new Thief();</p>
84
85 <p>alert(steve.money); // alerts '$$$'
86 steve.printMoney(); // alerts '$$$$$$$'</p>
87 </div></div></div><div id="property-create" class="member ni"><a href="Ext.Base.html#property-create" rel="property-create" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-property-create" class="viewSource">view source</a></div><a name="create"></a><a name="property-create"></a><a href="Ext.Base.html#" rel="property-create" class="cls expand">create</a><span> : Function</span></div><div class="description"><div class="short">Create a new instance of this Class.
88 Ext.define('My.cool.Class', {
89
90 ...
91
92
93 });
94
95 My.cool.Class.create({
96
97 someConfig: tr...</div><div class="long"><p>Create a new instance of this Class.
98 Ext.define('My.cool.Class', {</p>
99
100 <pre><code>...
101 </code></pre>
102
103 <p>});</p>
104
105 <p>My.cool.Class.create({</p>
106
107 <pre><code>someConfig: true
108 </code></pre>
109
110 <p>});</p>
111 </div></div></div><div id="property-createAlias" class="member ni"><a href="Ext.Base.html#property-createAlias" rel="property-createAlias" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-property-createAlias" class="viewSource">view source</a></div><a name="createAlias"></a><a name="property-createAlias"></a><a href="Ext.Base.html#" rel="property-createAlias" class="cls expand">createAlias</a><span> : Function</span></div><div class="description"><div class="short">Create aliases for existing prototype methods. Example:
112
113 Ext.define('My.cool.Class', {
114     method1: function() { ... ...</div><div class="long"><p>Create aliases for existing prototype methods. Example:</p>
115
116 <pre><code>Ext.define('My.cool.Class', {
117     method1: function() { ... },
118     method2: function() { ... }
119 });
120
121 var test = new My.cool.Class();
122
123 My.cool.Class.createAlias({
124     method3: 'method1',
125     method4: 'method2'
126 });
127
128 test.method3(); // test.method1()
129
130 My.cool.Class.createAlias('method5', 'method3');
131
132 test.method5(); // test.method3() -&gt; test.method1()
133 </code></pre>
134 </div></div></div><div id="property-implement" class="member ni"><a href="Ext.Base.html#property-implement" rel="property-implement" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-property-implement" class="viewSource">view source</a></div><a name="implement"></a><a name="property-implement"></a><a href="Ext.Base.html#" rel="property-implement" class="cls expand">implement</a><span> : Function</span></div><div class="description"><div class="short">Add methods / properties to the prototype of this class.
135
136 Ext.define('My.awesome.Cat', {
137     constructor: function() ...</div><div class="long"><p>Add methods / properties to the prototype of this class.</p>
138
139 <pre><code>Ext.define('My.awesome.Cat', {
140     constructor: function() {
141         ...
142     }
143 });
144
145  My.awesome.Cat.implement({
146      meow: function() {
147         alert('Meowww...');
148      }
149  });
150
151  var kitty = new My.awesome.Cat;
152  kitty.meow();
153 </code></pre>
154 </div></div></div><div id="property-override" class="member ni"><a href="Ext.Base.html#property-override" rel="property-override" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-property-override" class="viewSource">view source</a></div><a name="override"></a><a name="property-override"></a><a href="Ext.Base.html#" rel="property-override" class="cls expand">override</a><span> : Function</span></div><div class="description"><div class="short">Override prototype members of this class. Overridden methods can be invoked via
155 callOverridden
156
157 Ext.define('My.Cat', ...</div><div class="long"><p>Override prototype members of this class. Overridden methods can be invoked via
158 <a href="Ext.Base.html#callOverridden" rel="Ext.Base#callOverridden" class="docClass">callOverridden</a></p>
159
160 <pre><code>Ext.define('My.Cat', {
161     constructor: function() {
162         alert("I'm a cat!");
163
164         return this;
165     }
166 });
167
168 My.Cat.override({
169     constructor: function() {
170         alert("I'm going to be a cat!");
171
172         var instance = this.callOverridden();
173
174         alert("Meeeeoooowwww");
175
176         return instance;
177     }
178 });
179
180 var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
181                           // alerts "I'm a cat!"
182                           // alerts "Meeeeoooowwww"
183 </code></pre>
184 </div></div></div></div><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-callOverridden" class="member f ni"><a href="Ext.Base.html#method-callOverridden" rel="method-callOverridden" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-method-callOverridden" class="viewSource">view source</a></div><a name="callOverridden"></a><a name="method-callOverridden"></a><a href="Ext.Base.html#" rel="method-callOverridden" class="cls expand">callOverridden</a>(
185 <span class="pre">Array/Arguments args</span>)
186  : Mixed</div><div class="description"><div class="short">Call the original method that was previously overridden with override
187
188 Ext.define('My.Cat', {
189     constructor: functi...</div><div class="long"><p>Call the original method that was previously overridden with <a href="Ext.Base.html#override" rel="Ext.Base#override" class="docClass">override</a></p>
190
191 <pre><code>Ext.define('My.Cat', {
192     constructor: function() {
193         alert("I'm a cat!");
194
195         return this;
196     }
197 });
198
199 My.Cat.override({
200     constructor: function() {
201         alert("I'm going to be a cat!");
202
203         var instance = this.callOverridden();
204
205         alert("Meeeeoooowwww");
206
207         return instance;
208     }
209 });
210
211 var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
212                           // alerts "I'm a cat!"
213                           // alerts "Meeeeoooowwww"
214 </code></pre>
215 <h3 class="pa">Parameters</h3><ul><li><span class="pre">args</span> : Array/Arguments<div class="sub-desc"><p>The arguments, either an array or the <code>arguments</code> object</p>
216 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Mixed</span>&nbsp; &nbsp;<p>Returns the result after calling the overridden method</p>
217 </li></ul></div></div></div><div id="method-getName" class="member ni"><a href="Ext.Base.html#method-getName" rel="method-getName" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Base.html" class="definedIn docClass">Ext.Base</a><br/><a href="../source/Base3.html#Ext-Base-method-getName" class="viewSource">view source</a></div><a name="getName"></a><a name="method-getName"></a><a href="Ext.Base.html#" rel="method-getName" class="cls expand">getName</a> : String</div><div class="description"><div class="short">Get the current class' name in string format.
218
219 Ext.define('My.cool.Class', {
220     constructor: function() {
221         al...</div><div class="long"><p>Get the current class' name in string format.</p>
222
223 <pre><code>Ext.define('My.cool.Class', {
224     constructor: function() {
225         alert(this.self.getName()); // alerts 'My.cool.Class'
226     }
227 });
228
229 My.cool.Class.getName(); // 'My.cool.Class'
230 </code></pre>
231 <h3 class="pa">Returns</h3><ul><li><span class="pre">String</span>&nbsp; &nbsp;<p>className</p>
232 </li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>