1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <meta http-equiv="content-type" content="text/html; charset=undefined" />
8 <meta name="generator" content="JsDoc Toolkit" />
11 <title>JsDoc Reference - Roo.Template</title>
14 <link rel="stylesheet" type="text/css" href="../../css/roojs.css" />
15 <link rel="stylesheet" type="text/css" href="../default.css" />
18 <script type="text/javascript" src="../page.js">
25 <body onload="RooDocsPage.onload();">
28 <div class="body-wrap">
30 <!-- ============================== links to methods. ================================= -->
32 <div class="top-tools">
34 <a class="inner-link" href="#Roo.Template-props"><img src="resources/s.gif" class="item-icon icon-prop">Properties</a>
35 <a class="inner-link" href="#Roo.Template-methods"><img src="resources/s.gif" class="item-icon icon-method">Methods</a>
36 <a class="inner-link" href="#Roo.Template-events"><img src="resources/s.gif" class="item-icon icon-event">Events</a>
37 <a class="inner-link" href="#Roo.Template-configs"><img src="resources/s.gif" class="item-icon icon-config">Config Options</a>
38 <a class="bookmark" href="NEED_TO_CREATE_DIRECT_LINK_HREF"><img src="resources/s.gif" class="item-icon icon-fav">Direct Link</a>
43 <!-- ============================== inheritance Block. ================================= -->
45 <!-- ============================== class title / details ============================ -->
48 <h1 class="classTitle">
53 <table cellspacing="0" class="class-summary-table">
55 <tr><td class="label">Package:</td><td class="hd-info">Roo</td></tr>
57 <tr><td class="label">Defined In:</td><td class="hd-info">
59 <a href="./src/Roo_Template.js.html">Roo/Template.js</a>.
62 <tr><td class="label">Class:</td><td class="hd-info">Template</td></tr>
65 <tr><td class="label">Subclasses:</td><td class="hd-info">
66 <a href="./Roo.DomTemplate.html#constructor" roo:cls="Roo.DomTemplate.html#constructor">Roo.DomTemplate</a>, <a href="./Roo.MasterTemplate.html#constructor" roo:cls="Roo.MasterTemplate.html#constructor">Roo.MasterTemplate</a>, <a href="./Roo.XTemplate.html#constructor" roo:cls="Roo.XTemplate.html#constructor">Roo.XTemplate</a>
77 <!-- ============================== class summary ========================== -->
78 <div class="description">
79 Represents an HTML fragment template. Templates can be precompiled for greater performance.<br/>For a list of available format functions, see {<b>link</b> Roo.util.Format}.<br /><br/>Usage:<br/><pre><code><br/>var t = new Roo.Template({<br/> html : '<div name="{id}">' + <br/> '<span class="{cls}">{name:trim} {someval:this.myformat}{value:ellipsis(10)}</span>' +<br/> '</div>',<br/> myformat: function (value, allValues) {<br/> return 'XX' + value;<br/> }<br/>});<br/>t.append('some-element', {id: 'myid', cls: 'myclass', name: 'foo', value: 'bar'});<br/></code></pre><br/>For more information see this blog post with examples:<br/> <a href="http://www.cnitblog.com/seeyeah/archive/2011/12/30/38728.html/">DomHelper<br/> - Create Elements using DOM, HTML fragments and Templates</a>.
83 <!-- ============================== Class comment block... ========================== -->
85 <div class="comments">
86 <b>Class Comments / Notes</B> =>
87 <u onclick="parent.CommentDialog.showCommentId = 'Roo.Template';">[Add Your comment/notes about this class]</u>
89 <iframe frameborder="0" id="comments-Roo" style="border: none;width:100%;"
90 src="/blog.php/GtkDjsComments/Roo.Template.html"></iframe>
95 <!-- ============================== config options ========================== -->
100 <div class="hr"></div>
101 <a id="Roo.Template-configs"></a>
107 <table cellspacing="0" class="member-table">
108 <caption>Config Options (Usually are also Properties)</caption>
112 <th class="sig-header" colspan="2">Options</th>
114 <th class="msource-header">Defined By</th>
121 <tr class="config-row expandable config-row-alt0 notInherited">
122 <td class="micon"><a class="exi" href="#expand"> </a></td>
125 <a id="Roo.Template-cfg-html" name=".html"></a>
126 <div class="fixedFont">
127 <b class="itemname">html</b> : <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
133 <div class="short">The HTML fragment or an array of fragments to join("") or multiple arguments to join("")</div>
138 The HTML fragment or an array of fragments to join("") or multiple arguments to join("")
154 <tr class="config-row expandable config-row-alt1 notInherited">
155 <td class="micon"><a class="exi" href="#expand"> </a></td>
158 <a id="Roo.Template-cfg-url" name=".url"></a>
159 <div class="fixedFont">
160 <b class="itemname">url</b> : <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
166 <div class="short">The Url to load the template from.</div>
171 The Url to load the template from. beware if you are loading from a url, the data may not be ready if you use it instantly..<br/> it should be fixed so that template is observable...
197 <!-- ============================== public properties ==================== -->
201 <a id="Roo.Template-props"></a>
207 <table cellspacing="0" class="member-table">
208 <caption class="Empty">Public Properties - Has None</caption>
214 <!-- ============================== methods summary / details ======================== -->
217 <a id="Roo.Template-methods"></a>
218 <!-- constructor?? -->
225 <!-- then dynamics first -->
232 <table cellspacing="0" class="member-table">
233 <caption>Public Methods</caption>
235 <th class="sig-header" colspan="2">Method</th>
236 <th class="msource-header">Defined By</th>
246 <tr class="method-row config-row-alt0 expandable notInherited">
247 <td class="micon"><a class="exi" href="#expand"> </a></td>
251 <a id="Roo-method-Template" name=".Template"></a>
252 <div class="fixedFont">
253 <span class="attributes">new <B>Roo.</B></span><b class="itemname">Template</b>
255 (<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>cfg</i></B>)
263 <div class="short">Create a new Roo.Template</div>
270 Create a new Roo.Template
273 <dl class="detailList">
274 <dt class="heading">Parameters:</dt>
277 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>cfg</b>
280 <dd>- Configuration object.</dd>
304 <tr class="method-row config-row-alt1 expandable notInherited">
305 <td class="micon"><a class="exi" href="#expand"> </a></td>
309 <a id="Roo.Template-method-from" name=".from"></a>
310 <div class="fixedFont">
311 <span class="attributes">Roo.Template.</span><b class="itemname">from</b>
313 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement <B><i>el</i></B>)
320 <div class="short">Creates a template from the passed element's value (<i>display:none</i> textarea, preferred) or innerHTML.</div>
326 Creates a template from the passed element's value (<i>display:none</i> textarea, preferred) or innerHTML.
333 <dl class="detailList">
334 <dt class="heading">Parameters:</dt>
337 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement</span> <b>el</b>
340 <dd>A DOM element or its id</dd>
366 <tr class="method-row config-row-alt0 expandable notInherited">
367 <td class="micon"><a class="exi" href="#expand"> </a></td>
371 <a id="Roo.Template-method-append" name=".append"></a>
372 <div class="fixedFont">
373 <span class="attributes"></span><b class="itemname">append</b>
375 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
381 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
390 <div class="short">Applies the supplied values to the template and appends the new node(s) to el.</div>
396 Applies the supplied values to the template and appends the new node(s) to el.
403 <dl class="detailList">
404 <dt class="heading">Parameters:</dt>
407 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
410 <dd>The context element</dd>
413 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
416 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
419 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
422 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
430 <dl class="detailList">
431 <dt class="heading">Returns:</dt>
433 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
455 <tr class="method-row config-row-alt1 expandable notInherited">
456 <td class="micon"><a class="exi" href="#expand"> </a></td>
460 <a id="Roo.Template-method-apply" name=".apply"></a>
461 <div class="fixedFont">
462 <span class="attributes"></span><b class="itemname">apply</b>
471 <div class="short">Alias for {<b>link</b> <b>applyTemplate</b>}</div>
477 Alias for {<b>link</b> <b>applyTemplate</b>}
506 <tr class="method-row config-row-alt0 expandable notInherited">
507 <td class="micon"><a class="exi" href="#expand"> </a></td>
511 <a id="Roo.Template-method-applyTemplate" name=".applyTemplate"></a>
512 <div class="fixedFont">
513 <span class="attributes"></span><b class="itemname">applyTemplate</b>
515 (<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>)
521 <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
530 <div class="short">Returns an HTML fragment of this template with the specified values applied.</div>
536 Returns an HTML fragment of this template with the specified values applied.
543 <dl class="detailList">
544 <dt class="heading">Parameters:</dt>
547 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
550 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
558 <dl class="detailList">
559 <dt class="heading">Returns:</dt>
561 <dd><span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> The HTML fragment</dd>
583 <tr class="method-row config-row-alt1 expandable notInherited">
584 <td class="micon"><a class="exi" href="#expand"> </a></td>
588 <a id="Roo.Template-method-compile" name=".compile"></a>
589 <div class="fixedFont">
590 <span class="attributes"></span><b class="itemname">compile</b>
598 <a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a>
607 <div class="short">Compiles the template into an internal function, eliminating the RegEx overhead.</div>
613 Compiles the template into an internal function, eliminating the RegEx overhead.
624 <dl class="detailList">
625 <dt class="heading">Returns:</dt>
627 <dd><span class="fixedFont"><a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a></span> this</dd>
649 <tr class="method-row config-row-alt0 expandable notInherited">
650 <td class="micon"><a class="exi" href="#expand"> </a></td>
654 <a id="Roo.Template-method-insertAfter" name=".insertAfter"></a>
655 <div class="fixedFont">
656 <span class="attributes"></span><b class="itemname">insertAfter</b>
658 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
664 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
673 <div class="short">Applies the supplied values to the template and inserts the new node(s) after el.</div>
679 Applies the supplied values to the template and inserts the new node(s) after el.
686 <dl class="detailList">
687 <dt class="heading">Parameters:</dt>
690 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
693 <dd>The context element</dd>
696 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
699 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
702 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
705 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
713 <dl class="detailList">
714 <dt class="heading">Returns:</dt>
716 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
738 <tr class="method-row config-row-alt1 expandable notInherited">
739 <td class="micon"><a class="exi" href="#expand"> </a></td>
743 <a id="Roo.Template-method-insertBefore" name=".insertBefore"></a>
744 <div class="fixedFont">
745 <span class="attributes"></span><b class="itemname">insertBefore</b>
747 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
753 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
762 <div class="short">Applies the supplied values to the template and inserts the new node(s) before el.</div>
768 Applies the supplied values to the template and inserts the new node(s) before el.
775 <dl class="detailList">
776 <dt class="heading">Parameters:</dt>
779 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
782 <dd>The context element</dd>
785 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
788 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
791 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
794 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
802 <dl class="detailList">
803 <dt class="heading">Returns:</dt>
805 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
827 <tr class="method-row config-row-alt0 expandable notInherited">
828 <td class="micon"><a class="exi" href="#expand"> </a></td>
832 <a id="Roo.Template-method-insertFirst" name=".insertFirst"></a>
833 <div class="fixedFont">
834 <span class="attributes"></span><b class="itemname">insertFirst</b>
836 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
842 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
851 <div class="short">Applies the supplied values to the template and inserts the new node(s) as the first child of el.</div>
857 Applies the supplied values to the template and inserts the new node(s) as the first child of el.
864 <dl class="detailList">
865 <dt class="heading">Parameters:</dt>
868 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
871 <dd>The context element</dd>
874 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
877 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
880 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
883 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
891 <dl class="detailList">
892 <dt class="heading">Returns:</dt>
894 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
916 <tr class="method-row config-row-alt1 expandable notInherited">
917 <td class="micon"><a class="exi" href="#expand"> </a></td>
921 <a id="Roo.Template-method-overwrite" name=".overwrite"></a>
922 <div class="fixedFont">
923 <span class="attributes"></span><b class="itemname">overwrite</b>
925 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
931 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
940 <div class="short">Applies the supplied values to the template and overwrites the content of el with the new node(s).</div>
946 Applies the supplied values to the template and overwrites the content of el with the new node(s).
953 <dl class="detailList">
954 <dt class="heading">Parameters:</dt>
957 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
960 <dd>The context element</dd>
963 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
966 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
969 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
972 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
980 <dl class="detailList">
981 <dt class="heading">Returns:</dt>
983 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
1005 <tr class="method-row config-row-alt0 expandable notInherited">
1006 <td class="micon"><a class="exi" href="#expand"> </a></td>
1010 <a id="Roo.Template-method-set" name=".set"></a>
1011 <div class="fixedFont">
1012 <span class="attributes"></span><b class="itemname">set</b>
1014 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>html</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>compile</i></B>)
1020 <a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a>
1029 <div class="short">Sets the HTML used as the template and optionally compiles it.</div>
1035 Sets the HTML used as the template and optionally compiles it.
1042 <dl class="detailList">
1043 <dt class="heading">Parameters:</dt>
1046 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>html</b>
1052 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>compile</b>
1055 <dd>(optional) True to compile the template (defaults to undefined)</dd>
1063 <dl class="detailList">
1064 <dt class="heading">Returns:</dt>
1066 <dd><span class="fixedFont"><a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a></span> this</dd>
1080 <td class="msource">
1091 <!-- ============================== events summary / details ======================== -->
1094 <a id="Roo.Template-events"></a>
1100 <table cellspacing="0" class="member-table">
1101 <caption class="Empty">Events - Has None</caption>
1112 <!-- ============================== footer ================================= -->
1113 <div class="fineprint" style="clear:both">
1115 Documentation generated by <a href="http://www.akbkhome.com" target="_blankt">Introspection Doc Generator</a> on Tue Nov 03 2015 12:41:05 GMT+0800 (HKT)
1117 <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a>