#416 closed defect (fixed)
Menu2 menu items run application "onclick" even if disabled
Reported by: | Owned by: | ilia | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Widgets | Version: | 0.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
The Menu2 widget doesn't seem to provide for properly disabling application-specific actions when the item is disabled. The widget's onclick code properly avoids opening a submenu (if there is one), but doesn't control app-specific actions.
My proposal is to add a new event/method, which might be named "onChoose", and calling it from the widget's onclick code only when the menu item is enabled. Applications then attach actions to the "onChoose" event. My change as a patch:
@@ -497,8 +497,14 @@ this.parent.closeAll(); } + this.onChoose(); }, + onChoose: function(){ + + // placeholder for application actions + }, + highlightItem: function(){ dojo.html.addClass(this.domNode, 'dojoMenuItem2Hover');
Change History (4)
comment:1 Changed 15 years ago by
Owner: | changed from anonymous to ilia |
---|
comment:2 Changed 15 years ago by
Milestone: | → 0.3release |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Fixed in rev 3032.
comment:3 Changed 15 years ago by
From mail:
Yeah, I agree that
<div dojoType="MenuItem2" onClick="alert('hello world');">
is definitely a more compact syntax than using topics, especially since you can do everything in markup.
I think in the non-dojo case below, the onClick event WON'T get fired, right?
<button disabled="true" onClick="alert('hello world');">push me</button>
So, I've done the same for menu items.
Ilia updated MenuItem2 to use topics. onClick() calls
dojo.event.topic.publish(this.eventNames.engage, this);
(but only when enabled). But I'm not sure how you set the name of the event. By default, this.eventNames.engage=="". Ilia, can you explain?