问题描述
我正在使用PrimeFaces commandButton
发出Ajax请求.
我应该设置update
属性,以便除了某些特定组件以外,可以更新整个父窗体(假设我已经用styleClass="noupdate"
标记了它们).
我正在使用PrimeFaces 3.5,所以我认为PrimeFaces jQuery选择器可能会有所帮助.
我尝试过这样的事情:
I'm using a PrimeFaces commandButton
to issue an Ajax request.
I should set the update
attribute so that the whole parent form be updated EXCEPT for some specific components (Let's say I've tagged them with styleClass="noupdate"
).
I'm using PrimeFaces 3.5, so I think PrimeFaces JQuery Selectors may help.
I tried something like this:
<!-- ...some inputs/labels to be updated here... -->
<p:overlayPanel styleClass="noupdate">
<!-- ...some inputs/labels to be updated here... -->
<p:commandButton id="btnDoIt" value="Do it"
update="@(this.closest('form') :not(.noupdate))"/>
</p:overlayPanel>
但是它不起作用(我收到一个JavaScript语法错误).
有什么方法可以得到我需要的东西吗?
请注意:
1)表单ID未知,因为该按钮是复合组件的一部分,该组件可以由不同视图中的任何表单托管.
2)在我的示例中,必须不更新<p:overlayPanel>
本身,但是必须更新任何后代组件.
3)视图中有多种形式,我应该只处理当前"形式.
but it doesn't work (I get a JavaScript Syntax Error).
Is there a way to get what I need?
Notice that:
1) The form id is not known because the button is part of a composite component that can be hosted by any form in different views
2) In my example the <p:overlayPanel>
itself must not be updated, but any descendant component do.
3) There are more than one form in the view, and I should work on the "current" one only.
在此先感谢您能帮助我.
Thank you in advance to anyone can help me.
推荐答案
在this这样的东西="nofollow noreferrer"> PrimeFaces选择器. PrimeFaces选择器中绝对没有像$.closest()
这样的jQuery函数.它只能是纯与jQuery兼容的CSS选择器,而不是一些JavaScript代码. /p>
There's no such thing as this
in PrimeFaces selectors. There are definitely no jQuery functions like $.closest()
available in PrimeFaces selectors. It has just to be a pure jQuery-compatible CSS selector, not some JavaScript code.
<p:commandButton ... update="@(form :not(.noupdate))"/>
另请参见:
- 如何排除孩子父组件的ajax更新中的组件?
- How to exclude child component in ajax update of a parent component?
See also:
这篇关于Primefaces选择器:更新最接近的表单时如何排除某些组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!