X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/output/Ext.DomHelper.js diff --git a/docs/output/Ext.DomHelper.js b/docs/output/Ext.DomHelper.js new file mode 100644 index 00000000..75266fb8 --- /dev/null +++ b/docs/output/Ext.DomHelper.js @@ -0,0 +1 @@ +Ext.data.JsonP.Ext_DomHelper({"tagname":"class","html":"

Alternate names

Ext.core.DomHelper

Files

The DomHelper class provides a layer of abstraction from DOM and transparently supports creating\nelements via DOM or using HTML fragments. It also has the ability to create HTML fragment templates\nfrom your DOM building code.

\n\n\n\n\n

DomHelper element specification object

\n\n\n

A specification object is used when creating elements. Attributes of this object\nare assumed to be element attributes, except for 4 special attributes:\n

    \n
  • tag :
    The tag name of the element
  • \n
  • children : or cn
    An array of the\nsame kind of element definition objects to be created and appended. These can be nested\nas deep as you want.
  • \n
  • cls :
    The class attribute of the element.\nThis will end up being either the \"class\" attribute on a HTML fragment or className\nfor a DOM node, depending on whether DomHelper is using fragments or DOM.
  • \n
  • html :
    The innerHTML for the element
  • \n

\n\n\n

NOTE: For other arbitrary attributes, the value will currently not be automatically\nHTML-escaped prior to building the element's HTML string. This means that if your attribute value\ncontains special characters that would not normally be allowed in a double-quoted attribute value,\nyou must manually HTML-encode it beforehand (see Ext.String.htmlEncode) or risk\nmalformed HTML being created. This behavior may change in a future release.

\n\n\n\n\n

Insertion methods

\n\n\n

Commonly used insertion methods:\n

\n\n\n\n\n

Example

\n\n\n

This is an example, where an unordered list with 3 children items is appended to an existing\nelement with id 'my-div':
\n \n

var dh = Ext.DomHelper; // create shorthand alias\n// specification object\nvar spec = {\n    id: 'my-ul',\n    tag: 'ul',\n    cls: 'my-list',\n    // append children after creating\n    children: [     // may also specify 'cn' instead of 'children'\n        {tag: 'li', id: 'item0', html: 'List Item 0'},\n        {tag: 'li', id: 'item1', html: 'List Item 1'},\n        {tag: 'li', id: 'item2', html: 'List Item 2'}\n    ]\n};\nvar list = dh.append(\n    'my-div', // the context element 'my-div' can either be the id or the actual node\n    spec      // the specification object\n);\n 

\n\n\n

Element creation specification parameters in this class may also be passed as an Array of\nspecification objects. This can be used to insert multiple sibling nodes into an existing\ncontainer very efficiently. For example, to add more list items to the example above:\n

dh.append('my-ul', [\n    {tag: 'li', id: 'item3', html: 'List Item 3'},\n    {tag: 'li', id: 'item4', html: 'List Item 4'}\n]);\n

\n\n\n\n\n

Templating

\n\n\n

The real power is in the built-in templating. Instead of creating or appending any elements,\ncreateTemplate returns a Template object which can be used over and over to\ninsert new elements. Revisiting the example above, we could utilize templating this time:\n

// create the node\nvar list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});\n// get template\nvar tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});\n\nfor(var i = 0; i < 5, i++){\n    tpl.append(list, [i]); // use template to append to the actual node\n}\n

\n

An example using a template:\n

var html = '{2}';\n\nvar tpl = new Ext.DomHelper.createTemplate(html);\ntpl.append('blog-roll', ['link1', 'http://www.edspencer.net/', \"Ed's Site\"]);\ntpl.append('blog-roll', ['link2', 'http://www.dustindiaz.com/', \"Dustin's Site\"]);\n

\n\n

The same example using named parameters:\n

var html = '{text}';\n\nvar tpl = new Ext.DomHelper.createTemplate(html);\ntpl.append('blog-roll', {\n    id: 'link1',\n    url: 'http://www.edspencer.net/',\n    text: \"Ed's Site\"\n});\ntpl.append('blog-roll', {\n    id: 'link2',\n    url: 'http://www.dustindiaz.com/',\n    text: \"Dustin's Site\"\n});\n

\n\n

Compiling Templates

\n

Templates are applied using regular expressions. The performance is great, but if\nyou are adding a bunch of DOM elements using the same template, you can increase\nperformance even further by "compiling" the template.\nThe way \"compile()\" works is the template is parsed and\nbroken up at the different variable points and a dynamic function is created and eval'ed.\nThe generated function performs string concatenation of these parts and the passed\nvariables instead of using regular expressions.\n

var html = '{text}';\n\nvar tpl = new Ext.DomHelper.createTemplate(html);\ntpl.compile();\n\n//... use template like normal\n

\n\n

Performance Boost

\n

DomHelper will transparently create HTML fragments when it can. Using HTML fragments instead\nof DOM can significantly boost performance.

\n

Element creation specification parameters may also be strings. If useDom is false,\nthen the string is used as innerHTML. If useDom is true, a string specification\nresults in the creation of a text node. Usage:

\n
Ext.DomHelper.useDom = true; // force it to use DOM; reduces performance\n
\n\n
Defined By

Properties

 

True to force the use of DOM instead of html fragments

\n

True to force the use of DOM instead of html fragments

\n
Defined By

Methods

( String/HTMLElement/Ext.Element 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.

\n

Parameters

Returns

Applies a style specification to an element. ...

Applies a style specification to an element.

\n

Parameters

  • el : String/HTMLElement

    The element to apply styles to

    \n
  • styles : String/Object/Function

    A style specification string e.g. 'width:100px', or object in the form {width:'100px'}, or\na function which returns such a specification.

    \n
Creates new DOM element(s) without inserting them to the document. ...

Creates new DOM element(s) without inserting them to the document.

\n

Parameters

  • o : Object/String

    The DOM object spec (and children) or raw HTML blob

    \n

Returns

  • HTMLElement

    The new uninserted node

    \n
Creates a new Ext.Template from the DOM object spec. ...

Creates a new Ext.Template from the DOM object spec.

\n

Parameters

  • o : Object

    The DOM object spec (and children)

    \n

Returns

( String/HTMLElement/Ext.Element 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.

\n

Parameters

Returns

( String/HTMLElement/Ext.Element 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.

\n

Parameters

Returns

( String/HTMLElement/Ext.Element 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.

\n

Parameters

Returns

( String where, HTMLElement/TextNode el, String html ) : HTMLElement
Inserts an HTML fragment into the DOM. ...

Inserts an HTML fragment into the DOM.

\n

Parameters

  • where : String

    Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.

    \n\n

    For example take the following HTML: <div>Contents</div>

    \n\n

    Using different where values inserts element to the following places:

    \n\n
      \n
    • beforeBegin: <HERE><div>Contents</div>
    • \n
    • afterBegin: <div><HERE>Contents</div>
    • \n
    • beforeEnd: <div>Contents<HERE></div>
    • \n
    • afterEnd: <div>Contents</div><HERE>
    • \n
    \n\n
  • el : HTMLElement/TextNode

    The context element

    \n
  • html : String

    The HTML fragment

    \n

Returns

  • HTMLElement

    The new node

    \n
Returns the markup for the passed Element(s) config. ...

Returns the markup for the passed Element(s) config.

\n

Parameters

  • o : Object

    The DOM object spec (and children)

    \n

Returns

( String/HTMLElement/Ext.Element 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.

\n

Parameters

Returns

","allMixins":[],"meta":{},"requires":[],"deprecated":null,"extends":null,"inheritable":false,"static":false,"superclasses":[],"singleton":true,"code_type":"assignment","alias":null,"statics":{"property":[],"css_var":[],"css_mixin":[],"cfg":[],"method":[],"event":[]},"subclasses":[],"uses":[],"protected":false,"mixins":[],"members":{"property":[{"tagname":"property","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":null,"required":null,"protected":false,"name":"useDom","id":"property-useDom"}],"css_var":[],"css_mixin":[],"cfg":[],"method":[{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"append","id":"method-append"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"applyStyles","id":"method-applyStyles"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"createDom","id":"method-createDom"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"createTemplate","id":"method-createTemplate"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"insertAfter","id":"method-insertAfter"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"insertBefore","id":"method-insertBefore"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"insertFirst","id":"method-insertFirst"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"insertHtml","id":"method-insertHtml"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"markup","id":"method-markup"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.DomHelper","template":false,"required":null,"protected":false,"name":"overwrite","id":"method-overwrite"}],"event":[]},"private":false,"component":false,"name":"Ext.DomHelper","alternateClassNames":["Ext.core.DomHelper"],"id":"class-Ext.DomHelper","mixedInto":[],"xtypes":{},"files":[{"href":"DomHelper.html#Ext-DomHelper","filename":"DomHelper.js"}]}); \ No newline at end of file