From ef4885eb1a4bc02ed4aab9d21e225dc02ac9db4f Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 19 Aug 2021 11:25:02 +0800 Subject: [PATCH] fix menu item # triggering url change --- Roo/bootstrap/menu/Item.js | 4 ++-- roojs-bootstrap-debug.js | 4 ++-- roojs-bootstrap.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Roo/bootstrap/menu/Item.js b/Roo/bootstrap/menu/Item.js index 71bc4b5995..feab5f205c 100644 --- a/Roo/bootstrap/menu/Item.js +++ b/Roo/bootstrap/menu/Item.js @@ -108,9 +108,9 @@ Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, { }, onClick : function(e) { - Roo.log('item on click '); + //Roo.log('item on click '); - if(this.preventDefault){ + if(this.href === false || this.preventDefault){ e.preventDefault(); } //this.parent().hideMenuItems(); diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 6456a39282..21ccfdf2b8 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -4198,9 +4198,9 @@ Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, { }, onClick : function(e) { - Roo.log('item on click '); + //Roo.log('item on click '); - if(this.preventDefault){ + if(this.href === false || this.preventDefault){ e.preventDefault(); } //this.parent().hideMenuItems(); diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 23795c1e0b..7958bcce1a 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -185,7 +185,7 @@ xy=this.el.getAlignToXY(el,a[1]+'-'+a[0]+'?')}this.showAt(xy,B,false);},showAt:f Roo.bootstrap.menu.Item=function(A){Roo.bootstrap.menu.Item.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.menu.Item,Roo.bootstrap.Component,{href:false,html:false,preventDefault:false,isContainer:false,active:false,fa:false,getAutoCreate:function(){if(this.isContainer){return {tag:'li',cls:'dropdown-menu-item '} ;}var A={tag:'span',html:'Link'};var B={tag:'a',cls:'dropdown-item',href:'#',cn:[]};if(this.fa!==false){B.cn.push({tag:'i',cls:'fa fa-'+this.fa});}B.cn.push(A);var C={tag:'li',cls:'dropdown-menu-item',cn:[B]};if(this.parent().type=='treeview'){C.cls='treeview-menu'; }if(this.active){C.cls+=' active';}B.href=this.href||C.cn[0].href;A.html=this.html||C.cn[0].html;return C;},initEvents:function(){if(this.parent().type=='treeview'){this.el.select('a').on('click',this.onClick,this);}if(this.menu){this.menu.parentType=this.xtype; -this.menu.triggerEl=this.el;this.menu=this.addxtype(Roo.apply({},this.menu));}},onClick:function(e){Roo.log('item on click ');if(this.preventDefault){e.preventDefault();}this.fireEvent('click',this,e);},getEl:function(){return this.el;}}); +this.menu.triggerEl=this.el;this.menu=this.addxtype(Roo.apply({},this.menu));}},onClick:function(e){if(this.href===false||this.preventDefault){e.preventDefault();}this.fireEvent('click',this,e);},getEl:function(){return this.el;}}); // Roo/bootstrap/menu/Separator.js Roo.bootstrap.menu.Separator=function(A){Roo.bootstrap.menu.Separator.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.menu.Separator,Roo.bootstrap.Component,{getAutoCreate:function(){var A={tag:'li',cls:'dropdown-divider divider'};return A;} }); -- 2.39.2