简体   繁体   English

是否可以中止<f:ajax>用“return false”?</f:ajax>

[英]is it possible to abort <f:ajax> with “return false”?

If you do this:如果你这样做:

<h:commandButton action="..." onclick="return false" />

The action will not occur.该动作不会发生。

The same does not work for <f:ajax> , meaning this doesn't work:这对<f:ajax>不起作用,这意味着这不起作用:

<f:ajax event="click" onevent="return false" listener="#{mrBean.doSomething()}" >
    <h:commandLink value="A Link"  \>
</f:ajax>

Or more correctly, the ajax action runs and I get this error in the javascript console:或者更准确地说,ajax 操作运行,我在 javascript 控制台中收到此错误:

Uncaught SyntaxError: Unexpected token return
myfaces._impl.core._Runtime.singletonExtendClass.chainjsf.js.jsf:7491
chainjsf.js.jsf:7696
(anonymous function)file.jsf
onclick

Is there a way abort the <f:ajax> action through a javascript in a similar fashion to the h:commandbutton example?有没有办法以类似于h:commandbutton示例的方式通过 javascript 中止<f:ajax>操作?

I did this:我这样做了:

<f:ajax event="click" onevent="doTheRefreshingPart()" listener="#{mrBean.doSomething()}" >
    <h:commandLink value="A Link" onclick="return doTheConfirmationPart" \>
</f:ajax>

I moved the part that is confirmation dependent to the actual commandlink and left the part that takes part of refreshing the page in the <f:ajax> part我将确认依赖于实际的命令链接的部分移动了,并将负责刷新页面的部分留在了<f:ajax>部分中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM