2 |
aperonnet |
1 |
<div class="body-wrap">
|
|
|
2 |
<div class="top-tools">
|
|
|
3 |
<a class="inner-link" href="#Ext.DomHelper-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
|
|
|
4 |
<a class="inner-link" href="#Ext.DomHelper-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
|
|
|
5 |
<a class="inner-link" href="#Ext.DomHelper-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
|
|
|
6 |
<a class="bookmark" href="../docs/?class=Ext.DomHelper"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
|
|
|
7 |
</div>
|
|
|
8 |
<h1>Class Ext.DomHelper</h1>
|
|
|
9 |
<table cellspacing="0">
|
|
|
10 |
<tr><td class="label">Package:</td><td class="hd-info">Ext</td></tr>
|
|
|
11 |
<tr><td class="label">Defined In:</td><td class="hd-info"><a href="../source/core/DomHelper.js" target="_blank">DomHelper.js</a></td></tr>
|
|
|
12 |
<tr><td class="label">Class:</td><td class="hd-info">DomHelper</td></tr>
|
|
|
13 |
<tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
|
|
|
14 |
</table>
|
|
|
15 |
<div class="description">
|
|
|
16 |
Utility class for working with DOM and/or Templates. It transparently supports using HTML fragments or DOM.<br>
|
|
|
17 |
This is an example, where an unordered list with 5 children items is appended to an existing element with id 'my-div':<br>
|
|
|
18 |
<pre><code>var list = dh.append(<em>'my-div'</em>, {
|
|
|
19 |
id: <em>'my-ul'</em>, tag: <em>'ul'</em>, cls: <em>'my-list'</em>, children: [
|
|
|
20 |
{tag: <em>'li'</em>, id: <em>'item0'</em>, html: <em>'List Item 0'</em>},
|
|
|
21 |
{tag: <em>'li'</em>, id: <em>'item1'</em>, html: <em>'List Item 1'</em>},
|
|
|
22 |
{tag: <em>'li'</em>, id: <em>'item2'</em>, html: <em>'List Item 2'</em>},
|
|
|
23 |
{tag: <em>'li'</em>, id: <em>'item3'</em>, html: <em>'List Item 3'</em>},
|
|
|
24 |
{tag: <em>'li'</em>, id: <em>'item4'</em>, html: <em>'List Item 4'</em>}
|
|
|
25 |
]
|
|
|
26 |
});</code></pre>
|
|
|
27 |
<p>Element creation specification parameters in this class may also be passed as an Array of
|
|
|
28 |
specification objects. This can be used to insert multiple sibling nodes into an existing
|
|
|
29 |
container very efficiently. For example, to add more list items to the example above:<pre><code>dh.append(<em>'my-ul'</em>, [
|
|
|
30 |
{tag: <em>'li'</em>, id: <em>'item5'</em>, html: <em>'List Item 5'</em>},
|
|
|
31 |
{tag: <em>'li'</em>, id: <em>'item6'</em>, html: <em>'List Item 6'</em>} ]);</code></pre></p>
|
|
|
32 |
<p>Element creation specification parameters may also be strings. If <a ext:cls="useDom" href="output/useDom.html">useDom</a> is false, then the string is used
|
|
|
33 |
as innerHTML. If <a ext:cls="useDom" href="output/useDom.html">useDom</a> is true, a string specification results in the creation of a text node.</p>
|
|
|
34 |
For more information and examples, see <a href="http://www.jackslocum.com/blog/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">the original blog post</a>.<br><br><i>This class is a singleton and cannot be created directly.</i> </div>
|
|
|
35 |
|
|
|
36 |
<div class="hr"></div>
|
|
|
37 |
<a id="Ext.DomHelper-props"></a>
|
|
|
38 |
<h2>Public Properties</h2>
|
|
|
39 |
<table cellspacing="0" class="member-table">
|
|
|
40 |
<tr>
|
|
|
41 |
<th class="sig-header" colspan="2">Property</th>
|
|
|
42 |
<th class="msource-header">Defined By</th>
|
|
|
43 |
</tr>
|
|
|
44 |
<tr class="property-row">
|
|
|
45 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
46 |
<td class="sig">
|
|
|
47 |
<a id="Ext.DomHelper-useDom"></a>
|
|
|
48 |
<b>useDom</b> : Boolean <div class="mdesc">
|
|
|
49 |
True to force the use of DOM instead of html fragments </div>
|
|
|
50 |
</td>
|
|
|
51 |
<td class="msource">DomHelper</td>
|
|
|
52 |
</tr>
|
|
|
53 |
</table>
|
|
|
54 |
<a id="Ext.DomHelper-methods"></a>
|
|
|
55 |
<h2>Public Methods</h2>
|
|
|
56 |
<table cellspacing="0" class="member-table">
|
|
|
57 |
<tr>
|
|
|
58 |
<th class="sig-header" colspan="2">Method</th>
|
|
|
59 |
<th class="msource-header">Defined By</th>
|
|
|
60 |
</tr>
|
|
|
61 |
<tr class="method-row expandable">
|
|
|
62 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
63 |
<td class="sig">
|
|
|
64 |
<a id="Ext.DomHelper-append"></a>
|
|
|
65 |
<b>append</b>( <code>Mixed el</code>, <code>Object/String o</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
|
|
|
66 |
<div class="short">Creates new DOM element(s) and appends them to el.</div>
|
|
|
67 |
<div class="long">
|
|
|
68 |
Creates new DOM element(s) and appends them to el. <div class="mdetail-params">
|
|
|
69 |
<strong>Parameters:</strong>
|
|
|
70 |
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>o</code> : Object/String<div class="sub-desc">The DOM object spec (and children) or raw HTML blob</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
|
|
|
71 |
<strong>Returns:</strong>
|
|
|
72 |
<ul>
|
|
|
73 |
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node</div></li>
|
|
|
74 |
</ul>
|
|
|
75 |
</div>
|
|
|
76 |
</div>
|
|
|
77 |
</div>
|
|
|
78 |
</td>
|
|
|
79 |
<td class="msource">DomHelper</td>
|
|
|
80 |
</tr>
|
|
|
81 |
<tr class="method-row alt expandable">
|
|
|
82 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
83 |
<td class="sig">
|
|
|
84 |
<a id="Ext.DomHelper-applyStyles"></a>
|
|
|
85 |
<b>applyStyles</b>( <code>String/HTMLElement el</code>, <code>String/Object/Function styles</code> ) : void <div class="mdesc">
|
|
|
86 |
<div class="short">Applies a style specification to an element.</div>
|
|
|
87 |
<div class="long">
|
|
|
88 |
Applies a style specification to an element. <div class="mdetail-params">
|
|
|
89 |
<strong>Parameters:</strong>
|
|
|
90 |
<ul><li><code>el</code> : String/HTMLElement<div class="sub-desc">The element to apply styles to</div></li><li><code>styles</code> : String/Object/Function<div class="sub-desc">A style specification string eg "width:100px", or object in the form {width:"100px"}, or
|
|
|
91 |
a function which returns such a specification.</div></li> </ul>
|
|
|
92 |
<strong>Returns:</strong>
|
|
|
93 |
<ul>
|
|
|
94 |
<li><code>void</code></li>
|
|
|
95 |
</ul>
|
|
|
96 |
</div>
|
|
|
97 |
</div>
|
|
|
98 |
</div>
|
|
|
99 |
</td>
|
|
|
100 |
<td class="msource">DomHelper</td>
|
|
|
101 |
</tr>
|
|
|
102 |
<tr class="method-row expandable">
|
|
|
103 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
104 |
<td class="sig">
|
|
|
105 |
<a id="Ext.DomHelper-createTemplate"></a>
|
|
|
106 |
<b>createTemplate</b>( <code>Object o</code> ) : Ext.Template <div class="mdesc">
|
|
|
107 |
<div class="short">Creates a new Ext.Template from the DOM object spec.</div>
|
|
|
108 |
<div class="long">
|
|
|
109 |
Creates a new Ext.Template from the DOM object spec. <div class="mdetail-params">
|
|
|
110 |
<strong>Parameters:</strong>
|
|
|
111 |
<ul><li><code>o</code> : Object<div class="sub-desc">The DOM object spec (and children)</div></li> </ul>
|
|
|
112 |
<strong>Returns:</strong>
|
|
|
113 |
<ul>
|
|
|
114 |
<li><code>Ext.Template</code><div class="sub-desc">The new template</div></li>
|
|
|
115 |
</ul>
|
|
|
116 |
</div>
|
|
|
117 |
</div>
|
|
|
118 |
</div>
|
|
|
119 |
</td>
|
|
|
120 |
<td class="msource">DomHelper</td>
|
|
|
121 |
</tr>
|
|
|
122 |
<tr class="method-row alt expandable">
|
|
|
123 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
124 |
<td class="sig">
|
|
|
125 |
<a id="Ext.DomHelper-insertAfter"></a>
|
|
|
126 |
<b>insertAfter</b>( <code>Mixed el</code>, <code>Object o</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
|
|
|
127 |
<div class="short">Creates new DOM element(s) and inserts them after el.</div>
|
|
|
128 |
<div class="long">
|
|
|
129 |
Creates new DOM element(s) and inserts them after el. <div class="mdetail-params">
|
|
|
130 |
<strong>Parameters:</strong>
|
|
|
131 |
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>o</code> : Object<div class="sub-desc">The DOM object spec (and children)</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
|
|
|
132 |
<strong>Returns:</strong>
|
|
|
133 |
<ul>
|
|
|
134 |
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node</div></li>
|
|
|
135 |
</ul>
|
|
|
136 |
</div>
|
|
|
137 |
</div>
|
|
|
138 |
</div>
|
|
|
139 |
</td>
|
|
|
140 |
<td class="msource">DomHelper</td>
|
|
|
141 |
</tr>
|
|
|
142 |
<tr class="method-row expandable">
|
|
|
143 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
144 |
<td class="sig">
|
|
|
145 |
<a id="Ext.DomHelper-insertBefore"></a>
|
|
|
146 |
<b>insertBefore</b>( <code>Mixed el</code>, <code>Object/String o</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
|
|
|
147 |
<div class="short">Creates new DOM element(s) and inserts them before el.</div>
|
|
|
148 |
<div class="long">
|
|
|
149 |
Creates new DOM element(s) and inserts them before el. <div class="mdetail-params">
|
|
|
150 |
<strong>Parameters:</strong>
|
|
|
151 |
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>o</code> : Object/String<div class="sub-desc">The DOM object spec (and children) or raw HTML blob</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
|
|
|
152 |
<strong>Returns:</strong>
|
|
|
153 |
<ul>
|
|
|
154 |
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node</div></li>
|
|
|
155 |
</ul>
|
|
|
156 |
</div>
|
|
|
157 |
</div>
|
|
|
158 |
</div>
|
|
|
159 |
</td>
|
|
|
160 |
<td class="msource">DomHelper</td>
|
|
|
161 |
</tr>
|
|
|
162 |
<tr class="method-row alt expandable">
|
|
|
163 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
164 |
<td class="sig">
|
|
|
165 |
<a id="Ext.DomHelper-insertFirst"></a>
|
|
|
166 |
<b>insertFirst</b>( <code>Mixed el</code>, <code>Object/String o</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
|
|
|
167 |
<div class="short">Creates new DOM element(s) and inserts them as the first child of el.</div>
|
|
|
168 |
<div class="long">
|
|
|
169 |
Creates new DOM element(s) and inserts them as the first child of el. <div class="mdetail-params">
|
|
|
170 |
<strong>Parameters:</strong>
|
|
|
171 |
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>o</code> : Object/String<div class="sub-desc">The DOM object spec (and children) or raw HTML blob</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
|
|
|
172 |
<strong>Returns:</strong>
|
|
|
173 |
<ul>
|
|
|
174 |
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node</div></li>
|
|
|
175 |
</ul>
|
|
|
176 |
</div>
|
|
|
177 |
</div>
|
|
|
178 |
</div>
|
|
|
179 |
</td>
|
|
|
180 |
<td class="msource">DomHelper</td>
|
|
|
181 |
</tr>
|
|
|
182 |
<tr class="method-row expandable">
|
|
|
183 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
184 |
<td class="sig">
|
|
|
185 |
<a id="Ext.DomHelper-insertHtml"></a>
|
|
|
186 |
<b>insertHtml</b>( <code>String where</code>, <code>HTMLElement el</code>, <code>String html</code> ) : HTMLElement <div class="mdesc">
|
|
|
187 |
<div class="short">Inserts an HTML fragment into the DOM.</div>
|
|
|
188 |
<div class="long">
|
|
|
189 |
Inserts an HTML fragment into the DOM. <div class="mdetail-params">
|
|
|
190 |
<strong>Parameters:</strong>
|
|
|
191 |
<ul><li><code>where</code> : String<div class="sub-desc">Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.</div></li><li><code>el</code> : HTMLElement<div class="sub-desc">The context element</div></li><li><code>html</code> : String<div class="sub-desc">The HTML fragmenet</div></li> </ul>
|
|
|
192 |
<strong>Returns:</strong>
|
|
|
193 |
<ul>
|
|
|
194 |
<li><code>HTMLElement</code><div class="sub-desc">The new node</div></li>
|
|
|
195 |
</ul>
|
|
|
196 |
</div>
|
|
|
197 |
</div>
|
|
|
198 |
</div>
|
|
|
199 |
</td>
|
|
|
200 |
<td class="msource">DomHelper</td>
|
|
|
201 |
</tr>
|
|
|
202 |
<tr class="method-row alt expandable">
|
|
|
203 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
204 |
<td class="sig">
|
|
|
205 |
<a id="Ext.DomHelper-markup"></a>
|
|
|
206 |
<b>markup</b>( <code>Object o</code> ) : String <div class="mdesc">
|
|
|
207 |
<div class="short">Returns the markup for the passed Element(s) config.</div>
|
|
|
208 |
<div class="long">
|
|
|
209 |
Returns the markup for the passed Element(s) config. <div class="mdetail-params">
|
|
|
210 |
<strong>Parameters:</strong>
|
|
|
211 |
<ul><li><code>o</code> : Object<div class="sub-desc">The DOM object spec (and children)</div></li> </ul>
|
|
|
212 |
<strong>Returns:</strong>
|
|
|
213 |
<ul>
|
|
|
214 |
<li><code>String</code></li>
|
|
|
215 |
</ul>
|
|
|
216 |
</div>
|
|
|
217 |
</div>
|
|
|
218 |
</div>
|
|
|
219 |
</td>
|
|
|
220 |
<td class="msource">DomHelper</td>
|
|
|
221 |
</tr>
|
|
|
222 |
<tr class="method-row expandable">
|
|
|
223 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
224 |
<td class="sig">
|
|
|
225 |
<a id="Ext.DomHelper-overwrite"></a>
|
|
|
226 |
<b>overwrite</b>( <code>Mixed el</code>, <code>Object/String o</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
|
|
|
227 |
<div class="short">Creates new DOM element(s) and overwrites the contents of el with them.</div>
|
|
|
228 |
<div class="long">
|
|
|
229 |
Creates new DOM element(s) and overwrites the contents of el with them. <div class="mdetail-params">
|
|
|
230 |
<strong>Parameters:</strong>
|
|
|
231 |
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>o</code> : Object/String<div class="sub-desc">The DOM object spec (and children) or raw HTML blob</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
|
|
|
232 |
<strong>Returns:</strong>
|
|
|
233 |
<ul>
|
|
|
234 |
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node</div></li>
|
|
|
235 |
</ul>
|
|
|
236 |
</div>
|
|
|
237 |
</div>
|
|
|
238 |
</div>
|
|
|
239 |
</td>
|
|
|
240 |
<td class="msource">DomHelper</td>
|
|
|
241 |
</tr>
|
|
|
242 |
</table>
|
|
|
243 |
<a id="Ext.DomHelper-events"></a>
|
|
|
244 |
<h2>Public Events</h2>
|
|
|
245 |
<div class="no-members">This class has no public events.</div>
|
|
|
246 |
</div>
|