Roo/form/TextItem.js
[roojs1] / Roo / form / TextItem.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  
12 /**
13  * @class Roo.form.TextItem
14  * @extends Roo.BoxComponent
15  * Base class for form fields that provides default event handling, sizing, value handling and other functionality.
16  * @constructor
17  * Creates a new TextItem
18  * @param {Object} config Configuration options
19  */
20 Roo.form.TextItem = function(config){
21     Roo.form.TextItem.superclass.constructor.call(this, config);
22 };
23
24 Roo.extend(Roo.form.TextItem, Roo.BoxComponent,  {
25     
26     /**
27      * @cfg {String} tag the tag for this item (default div)
28      */
29     tag : 'div',
30     /**
31      * @cfg {String} html the content for this item
32      */
33     html : '',
34     
35     getAutoCreate : function()
36     {
37         var cfg = {
38             id: this.id,
39             tag: this.tag,
40             html: this.html,
41             cls: 'x-form-item'
42         };
43         
44         return cfg;
45         
46     },
47     
48     onRender : function(ct, position)
49     {
50         Roo.form.TextItem.superclass.onRender.call(this, ct, position);
51         
52         if(!this.el){
53             var cfg = this.getAutoCreate();
54             if(!cfg.name){
55                 cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
56             }
57             if (!cfg.name.length) {
58                 delete cfg.name;
59             }
60             this.el = ct.createChild(cfg, position);
61         }
62     },
63     /*
64      * setHTML
65      * @param {String} html update the Contents of the element.
66      */
67     setHTML : funciton(html)
68     {
69         this.fieldEl.dom.innerHTML = html;
70     }
71     
72 });