Upgrade to ExtJS 3.1.0 - Released 12/16/2009
[extjs.git] / src / widgets / menu / Item.js
index 9160ef3..d49c47a 100644 (file)
@@ -1,5 +1,5 @@
 /*!
- * Ext JS Library 3.0.3
+ * Ext JS Library 3.1.0
  * Copyright(c) 2006-2009 Ext JS, LLC
  * licensing@extjs.com
  * http://www.extjs.com/license
  * @param {Object} config Configuration options\r
  * @xtype menuitem\r
  */\r
-Ext.menu.Item = function(config){\r
-    Ext.menu.Item.superclass.constructor.call(this, config);\r
-    if(this.menu){\r
-        this.menu = Ext.menu.MenuMgr.get(this.menu);\r
-    }\r
-};\r
-Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {\r
+Ext.menu.Item = Ext.extend(Ext.menu.BaseItem, {\r
     /**\r
      * @property menu\r
      * @type Ext.menu.Menu\r
@@ -66,6 +60,14 @@ Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {
     // private\r
     ctype: 'Ext.menu.Item',\r
 \r
+    initComponent : function(){\r
+        Ext.menu.Item.superclass.initComponent.call(this);\r
+        if(this.menu){\r
+            this.menu = Ext.menu.MenuMgr.get(this.menu);\r
+            this.menu.ownerCt = this;\r
+        }\r
+    },\r
+\r
     // private\r
     onRender : function(container, position){\r
         if (!this.itemTpl) {\r
@@ -84,6 +86,9 @@ Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {
         this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);\r
         this.iconEl = this.el.child('img.x-menu-item-icon');\r
         this.textEl = this.el.child('.x-menu-item-text');\r
+        if(!this.href) { // if no link defined, prevent the default anchor event\r
+            this.mon(this.el, 'click', Ext.emptyFn, null, { preventDefault: true });\r
+        }\r
         Ext.menu.Item.superclass.onRender.call(this, container, position);\r
     },\r
 \r
@@ -122,10 +127,11 @@ Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {
             this.iconEl.replaceClass(oldCls, this.iconCls);\r
         }\r
     },\r
-    \r
+\r
     //private\r
     beforeDestroy: function(){\r
         if (this.menu){\r
+            delete this.menu.ownerCt;\r
             this.menu.destroy();\r
         }\r
         Ext.menu.Item.superclass.beforeDestroy.call(this);\r