我有一个在我的网络应用程序中生成的 html openlayers 弹出窗口,其中包含一个带有菜单的 JQuery 按钮。菜单显示正常,但select
菜单事件仅第一次触发,此后不再响应。任何想法为什么?
这是Javascript
$("#popup_actions")
.button({
text: false,
icons: {
primary: "ui-icon-gear",
secondary: "ui-icon-triangle-1-s"
}
})
.click(function () {
console.log(this);
var menu = $(this).parent().next().show().position({
my: "left top",
at: "left bottom",
of: this
});
// "chicken" (ahem) is the name of the containing div, for some reason using $(document) didn't work
$("#chicken").one("click", function () {
menu.hide();
});
return false;
})
.parent()
.buttonset()
.next()
.hide()
.menu({select: function(e) {
console.log("The menu was selected", event);
}});
和 HTML:
<div style="width:60px;float:left">
<div>
<button id="popup_actions">Actions</button>
</div>
<ul style="width:200px">
<li><a href="#"><span class="ui-icon ui-icon-star"></span>Find in rack</a></li>
<li><a href="#"><span class="ui-icon ui-icon-star"></span>Find in tree</a></li>
<li><a href="#"><span class="ui-icon ui-icon-star"></span>Change Activity Report</a></li>
<li><a href="#"><span class="ui-icon ui-icon-star"></span>Link State Change History Report</a></li>
</ul>
</div>
编辑:
我设法把它变成了一个显示行为不起作用的jsfiddle。这绝对是 OpenLayers 的问题。http://jsfiddle.net/mattwoberts/JRmKN/13/ - 向地图添加一个多边形,然后进入弹出模式并打开弹出窗口以查看菜单 - 选择事件只会触发一次。