Roo/bootstrap/MenuItem.js
authorEdward <edward@roojs.com>
Wed, 16 Apr 2014 11:55:39 +0000 (19:55 +0800)
committerEdward <edward@roojs.com>
Wed, 16 Apr 2014 11:55:39 +0000 (19:55 +0800)
Roo/bootstrap/MenuItem.js

index 524423e..89fc634 100644 (file)
@@ -12,6 +12,7 @@
  * Bootstrap MenuItem class
  * @cfg {String} html the menu label
  * @cfg {String} href the link
+ * @cfg {Boolean} preventDefault (true | false) default true
  * 
  * 
  * @constructor
 
 Roo.bootstrap.MenuItem = function(config){
     Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
+    this.addEvents({
+        // raw events
+        /**
+         * @event click
+         * The raw click event for the entire grid.
+         * @param {Roo.EventObject} e
+         */
+        "click" : true
+    });
 };
 
 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
     
     href : false,
     html : false,
+    preventDefault: true,
     
     getAutoCreate : function(){
         var cfg= {
@@ -44,6 +55,21 @@ Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
         cfg.cn[0].href = this.href || cfg.cn[0].href ;
         cfg.cn[0].html = this.html || cfg.cn[0].html ;
         return cfg;
+    },
+    
+    initEvents: function() {
+        
+        this.el.on('click', this.onClick, this);
+        
+    },
+    onClick : function(e)
+    {
+        Roo.log('item on click ');
+        if(this.preventDefault){
+            e.preventDefault();
+        }
+        
+        this.fireEvent('click', this, e);
     }
    
 });