Roo/bootstrap/MenuItem.js
[roojs1] / Roo / bootstrap / MenuItem.js
1 /*
2  * - LGPL
3  *
4  * menu item
5  * 
6  */
7
8
9 /**
10  * @class Roo.bootstrap.MenuItem
11  * @extends Roo.bootstrap.Component
12  * Bootstrap MenuItem class
13  * @cfg {String} html the menu label
14  * @cfg {String} href the link
15  * @cfg {Boolean} preventDefault (true | false) default true
16  * 
17  * 
18  * @constructor
19  * Create a new MenuItem
20  * @param {Object} config The config object
21  */
22
23
24 Roo.bootstrap.MenuItem = function(config){
25     Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
26     this.addEvents({
27         // raw events
28         /**
29          * @event click
30          * The raw click event for the entire grid.
31          * @param {Roo.EventObject} e
32          */
33         "click" : true
34     });
35 };
36
37 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
38     
39     href : false,
40     html : false,
41     preventDefault: true,
42     
43     getAutoCreate : function(){
44         var cfg= {
45             tag: 'li',
46             cn: [
47                 {
48                     tag : 'a',
49                     href : '#',
50                     html : 'Link'
51                 }
52             ]
53         };
54         
55         cfg.cn[0].href = this.href || cfg.cn[0].href ;
56         cfg.cn[0].html = this.html || cfg.cn[0].html ;
57         return cfg;
58     },
59     
60     initEvents: function() {
61         
62         this.el.on('click', this.onClick, this);
63         
64     },
65     onClick : function(e)
66     {
67         Roo.log('item on click ');
68         if(this.preventDefault){
69             e.preventDefault();
70         }
71         
72         this.fireEvent('click', this, e);
73     }
74    
75 });
76
77  
78
79