EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on January 25, 2015, 06:58:56 PM



Title: adding menu items
Post by: devnull on January 25, 2015, 06:58:56 PM
The onclick event for a menus added as per this does not appear to fire.

Code:
$('#mm').menu('appendItem', {
parent: item.target,  // the parent item element
text: 'Open Excel',
iconCls: 'icon-excel',
onclick: function(){alert('Open Excel')}
});

If I add using this method, then the onclick event fires when the menu is added:

Code:
$('#mm').menu('appendItem', {
parent: item.target,  // the parent item element
text: 'Open Excel',
iconCls: 'icon-excel',
onclick: alert('Open Excel')
});


Title: Re: adding menu items
Post by: stworthy on January 26, 2015, 12:06:09 AM
The 'onclick' property value should be a string or a function.
Code:
onclick: function(){alert('Open Excel')
or
Code:
onclick: "alert('Open Excel')"