| Package: | Ext |
| Defined In: | DomHelper.js |
| Class: | DomHelper |
| Extends: | Object |
var dh = Ext.DomHelper;
var list = dh.append('my-div', {
id: 'my-ul', tag: 'ul', cls: 'my-list', children: [
{tag: 'li', id: 'item0', html: 'List Item 0'},
{tag: 'li', id: 'item1', html: 'List Item 1'},
{tag: 'li', id: 'item2', html: 'List Item 2'},
{tag: 'li', id: 'item3', html: 'List Item 3'},
{tag: 'li', id: 'item4', html: 'List Item 4'}
]
});
Element creation specification parameters in this class may also be passed as an Array of specification objects. This can be used to insert multiple sibling nodes into an existing container very efficiently. For example, to add more list items to the example above:
dh.append('my-ul', [
{tag: 'li', id: 'item5', html: 'List Item 5'},
{tag: 'li', id: 'item6', html: 'List Item 6'} ]);
Element creation specification parameters may also be strings. If useDom is false, then the string is used as innerHTML. If useDom is true, a string specification results in the creation of a text node.
For more information and examples, see the original blog post.| Method | Defined By | |
|---|---|---|
append( Mixed el, Object/String o, [Boolean returnElement] )
:
HTMLElement/Ext.ElementCreates new DOM element(s) and appends them to el. Creates new DOM element(s) and appends them to el. Parameters:
| DomHelper | |
insertAfter( Mixed el, Object o, [Boolean returnElement] )
:
HTMLElement/Ext.ElementCreates new DOM element(s) and inserts them after el. Creates new DOM element(s) and inserts them after el. Parameters:
| DomHelper | |
insertBefore( Mixed el, Object/String o, [Boolean returnElement] )
:
HTMLElement/Ext.ElementCreates new DOM element(s) and inserts them before el. Creates new DOM element(s) and inserts them before el. Parameters:
| DomHelper | |
insertFirst( Mixed el, Object/String o, [Boolean returnElement] )
:
HTMLElement/Ext.ElementCreates new DOM element(s) and inserts them as the first child of el. Creates new DOM element(s) and inserts them as the first child of el. Parameters:
| DomHelper | |
insertHtml( String where, HTMLElement el, String html )
:
HTMLElementInserts an HTML fragment into the DOM. Inserts an HTML fragment into the DOM. Parameters:
| DomHelper | |
markup( Object o )
:
StringReturns the markup for the passed Element(s) config. Returns the markup for the passed Element(s) config. Parameters:
| DomHelper | |
overwrite( Mixed el, Object/String o, [Boolean returnElement] )
:
HTMLElement/Ext.ElementCreates new DOM element(s) and overwrites the contents of el with them. Creates new DOM element(s) and overwrites the contents of el with them. Parameters:
| DomHelper | |