我正在尝试关闭一个dojo menuItem,但不确定正确的调用是什么。
我有以下代码来打开menuItem onHover:
dijit._MenuBase.prototype.onItemHover = function(item) {
if(this.isActive || this.allowSubmenuHover) {
this.focusChild(item);
if(this.focusedChild.popup && !this.focusedChild.disabled && !this.hover_timer){
this.hover_timer = setTimeout(dojo.hitch(this, '_openPopup'), this.popupDelay);
}
}
if(this.focusedChild){
this.focusChild(item);
}
this._hoveredChild = item;
};当menuItem失去焦点时,我现在就有这样的功能:
dijit._MenuBase.prototype.onItemUnhover = function(item) {
alert('hi');
};我只是不确定用什么替换alert语句来使menuItem关闭。
如果有人能帮我,我将不胜感激。
谢谢
发布于 2011-07-28 00:53:29
尝试这样做:(在调用此方法之前,您可能需要添加额外的检查,以查看鼠标是否不在子菜单上)
this._stopPopupTimer();
item._setSelected(false);
// Close all popups that are open and descendants of this menu
var itemPopup = item.popup;
if(itemPopup){
this._stopPendingCloseTimer(itemPopup);
itemPopup._pendingClose_timer = setTimeout(function(){
itemPopup._pendingClose_timer = null;
if(itemPopup.parentMenu){
itemPopup.parentMenu.currentPopup = null;
}
dijit.popup.close(itemPopup); // this calls onClose
}, this.popupDelay);
}发布于 2011-07-28 07:11:54
我们已经使用了以下代码:
dijit.popup.close(menuObject);使用menuObject作为您要关闭的菜单。如果你看一下dijit代码,它看起来就是他们关闭菜单的方式。
在我们的项目中,我们发现当关闭一个菜单时,有时它不会清除选择突出显示,因此下次打开它时,您选择的最后一项仍然突出显示。如果你遇到这个问题,试着使用:
dojo.query('.dijitMenuItemSelected', menuObject.domNode).removeClass('dijitMenuItemSelected');发布于 2011-07-16 05:54:19
这有帮助吗:http://dojo-toolkit.33424.n3.nabble.com/How-do-I-unfocus-the-menu-items-in-a-menu-td1597856.html?
您是否尝试过focus-ing另一个小部件(或隐藏项)?
警告:我不知道这是否真的有帮助
https://stackoverflow.com/questions/6702183
复制相似问题