我按照展示中的这个例子:http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=popup&sample=login&skin=blueSky 它显示了如何单击链接来打开弹出面板并将该面板附加到该链接的相同位置。但我希望如果我再次单击,它将关闭面板。有人知道如何实现这一目标吗?这是我的代码
<h:outputLink value="#" id="sb-dd-ol" >
<rich:componentControl event="click" operation="show" target="sb-dd-pp">
<a4j:param noEscape="true" value="event"/>
<rich:hashParam>
<a4j:param noEscape="true" name="top"
value="jQuery(#{rich:element('sb-dd-ol')}.parentNode).offset().top +
jQuery(#{rich:element('sb-dd-ol')}.parentNode).height()" />
<a4j:param noEscape="true" name="left"
value="jQuery(#{rich:element('sb-dd-ol')}.parentNode).offset().left" />
</rich:hashParam>
</rich:componentControl>
Test
</h:outputLink>
<rich:popupPanel id="sb-dd-pp" autosized="true" modal="false"
moveable="false" resizeable="false" followByScroll="false">
This is a test
</rich:popupPanel>
最佳答案
您可以扩展 PopupPanel 原型(prototype),如下所示:
jQuery.extend(RichFaces.ui.PopupPanel.prototype, {
toggle: function(event, opts) {
if (this.shown) {
this.hide(event, opts);
} else {
this.show(event, opts);
}
}
}
之后,您可以在 componentControl 中使用 operation="toggle"
(或者添加 onclick="#{rich:component('sb-dd-pp')}.toggle ();"
在链接上)。
关于jquery - 如何打开和关闭丰富的:popupPanel from the same link,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12736793/