gpt4 book ai didi

javascript - 如何防止select in tooltipdialog的select option操作触发onmouseleave事件

转载 作者:行者123 更新时间:2023-11-30 00:06:12 26 4
gpt4 key购买 nike

ToolTipDialog 中使用 dijit/form/Select。为对话框设置 mouselaveevent。但是当我尝试选择一个选项时会触发该事件。

fiddle 链接:select changes will trigger tooltipdialog onmouseleave

<script>
require([
"dojo/parser",
"dijit/registry",
"dijit/TooltipDialog",
"dijit/form/Select",
"dijit/popup",
"dojo/on",
"dojo/dom",
"dojo/domReady!"
], function(parser,registry,TooltipDialog,Select, popup, on, dom){
parser.parse();

var selHucode="";

var myTooltipDialog = new TooltipDialog({
id: 'myTooltipDialog',
style:'height:180px',
style: "width: 300px;",
content: '<div id="tpDialog" class="pDlg"></div><div id="btnGroup" class="left"><label for="name">selectP:</label> <input data-dojo-type="dijit/form/RadioButton">' +
'<br><label for="hobby"> 1111:</label> <input data-dojo-type="dijit/form/RadioButton"></div>'
+'<div id="selectMenu" class="right"> <select name="select1" id="sel" data-dojo-type="dijit/form/Select"> <option value="TN">Tennessee</option>'+
'<option value="VA" selected="selected">Virginia</option></select></div>' ,
onMouseLeave: function(e){

popup.close(myTooltipDialog);
},
onOpen:function(e){

var sHu=registry.byId("sel");

sHu.on("focus",function(e){
console.log(e);
})
selHucode=sHu.value;
// console.log(sHu.value);
}
});



on(dom.byId("ttt"),"mouseover" , function(e){

popup.open({
popup: myTooltipDialog,
orient: ["above-centered","above","below"],
around:dom.byId('ttt')

});

});


});
</script>

<span id="ttt"  >  tttt</span>

最佳答案

很简单:在您的 TooltipDialog onMouseLeave 事件中使用 registry getEnclosingWidget 方法检查鼠标是否悬停在选择上,如果它对应于您的选择名称 ('select1') 然后阻止关闭。

这是您要更改的代码:

onMouseLeave: function(e){
if(registry.getEnclosingWidget(e.target).name=="select1") return;
popup.close(myTooltipDialog);
}

如果你想检查,这里有一个 fiddle :Fiddle

关于javascript - 如何防止select in tooltipdialog的select option操作触发onmouseleave事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38431816/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com