Class Ext.DomHelper
Package: | Ext |
Defined In: | DomHelper.js |
Class: | DomHelper |
Extends: | Object |
Utility class for working with DOM and/or Templates. It transparently supports using HTML fragments or DOM.
This is an example, where an unordered list with 5 children items is appended to an existing element with id 'my-div':
var list = dh.append('my-div', {
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'}
]
});
For more information and examples, see
the original blog post.
This class is a singleton and cannot be created directly.
Public Properties
|
useDom : Boolean
True to force the use of DOM instead of html fragments
|
DomHelper |
Public Methods
|
append( Mixed el , Object/String o , [Boolean returnElement ] ) : HTMLElement/Ext.Element
Creates new DOM element(s) and appends them to el.
Creates new DOM element(s) and appends them to el.
Parameters:
Returns:
HTMLElement/Ext.Element The new node
|
DomHelper |
|
applyStyles( String/HTMLElement el , String/Object/Function styles ) : void
Applies a style specification to an element.
Applies a style specification to an element.
Parameters:
el : String/HTMLElementThe element to apply styles to styles : String/Object/FunctionA style specification string eg "width:100px", or object in the form {width:"100px"}, or
a function which returns such a specification.
Returns:
|
DomHelper |
|
createTemplate( Object o ) : Ext.Template
Creates a new Ext.Template from the DOM object spec.
Creates a new Ext.Template from the DOM object spec.
Parameters:
Returns:
Ext.Template The new template
|
DomHelper |
|
insertAfter( Mixed el , Object o , [Boolean returnElement ] ) : HTMLElement/Ext.Element
Creates new DOM element(s) and inserts them after el.
Creates new DOM element(s) and inserts them after el.
Parameters:
Returns:
HTMLElement/Ext.Element The new node
|
DomHelper |
|
insertBefore( Mixed el , Object/String o , [Boolean returnElement ] ) : HTMLElement/Ext.Element
Creates new DOM element(s) and inserts them before el.
Creates new DOM element(s) and inserts them before el.
Parameters:
Returns:
HTMLElement/Ext.Element The new node
|
DomHelper |
|
insertFirst( Mixed el , Object/String o , [Boolean returnElement ] ) : HTMLElement/Ext.Element
Creates 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:
Returns:
HTMLElement/Ext.Element The new node
|
DomHelper |
|
insertHtml( String where , HTMLElement el , String html ) : HTMLElement
Inserts an HTML fragment into the DOM.
Inserts an HTML fragment into the DOM.
|
DomHelper |
|
markup( Object o ) : String
Returns the markup for the passed Element(s) config.
Returns the markup for the passed Element(s) config.
|
DomHelper |
|
overwrite( Mixed el , Object/String o , [Boolean returnElement ] ) : HTMLElement/Ext.Element
Creates 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:
Returns:
HTMLElement/Ext.Element The new node
|
DomHelper |
Public Events
This class has no public events.