EasyUI Forum
March 28, 2024, 01:46:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Menu Click Bug  (Read 8469 times)
thiago_brum
Newbie
*
Posts: 26


View Profile Email
« on: April 27, 2018, 07:01:28 AM »

Hello. I upgrade from 1.5 to 1.5.5.
Now, when I click on a menu with submenus (
that is, without URL ou Javascript action defined), it tries to open a UNDEFINED page,
instead of displaying the submenu. How can I fix this?
Logged
thiago_brum
Newbie
*
Posts: 26


View Profile Email
« Reply #1 on: April 27, 2018, 07:05:57 AM »

My code...

    var data = ".json_encode($itens_menu[$sistema]).";

    createMenuBar(data, '#top-menu');
    
    function createMenuBar(data, container){
     $.map(data, function(btn){
         var b = $('<a href=\''+(btn.url != '' ? btn.url : '#')+'\'></a>').appendTo(container); // CLICK ERROR HERE
         if (btn.items){
             b.menubutton($.extend({}, btn, {
                 menu: createMenu(btn.items),
                 iconCls: btn.icon
             }));            
         } else {
             b.linkbutton($.extend({}, btn, {
                 plain: true,
                 iconCls: btn.icon
             }));
         }
     });
    
     function createMenu(items){
         var m = $('<div></div>').appendTo('body').menu();
         _create(items);
         return m;
 
         function _create(items, p){
             $.map(items, function(item){
                 m.menu('appendItem', $.extend({}, item, {
                     iconCls: item.icon,
                     href: item.url,
                     parent: (p?p.target:null)
                 }));
                 if (item.items){
                     var p1 = m.menu('findItem', item.text);
                     _create(item.items, p1);
                 }
             });
         }
     }
    }


Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: April 27, 2018, 05:31:02 PM »

Please look at your code:
Code:
var b = $('<a href=\''+(btn.url != '' ? btn.url : '#')+'\'></a>').appendTo(container);

If you are missing the 'url' property, the '<a href="undefined"...>' will be rendered and will navigate you to a undefined page. To solve this issue, please use this code instead.
Code:
var b = $('<a href=\''+(btn.url != undefined ? btn.url : '#')+'\'></a>').appendTo(container);

This example works fine.
http://code.reloado.com/ewecip3/edit#html,live
Logged
thiago_brum
Newbie
*
Posts: 26


View Profile Email
« Reply #3 on: April 29, 2018, 06:44:17 AM »

Thanks for the help but doesn't fix my problem. In your example, if I click on the MenuButton, nothing happens. In 1.5 version, It's shows(open) the submenus (Item1,Item2).
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: April 29, 2018, 07:38:13 PM »

If you wish to display the drop-down menu by clicking the menubutton, please set 'showEvent' property to 'click'.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!