Primefaces编辑器和Ajax提交模糊 [英] Primefaces Editor and ajax submission on blur
问题描述
我的页面上有一个Primefaces编辑器,当用户关注页面上的其他组件时,我想将内容提交到服务器.
I have a Primefaces editor on my page and I want to submit the content to the server when the user focuses on a different component on the page.
<p:editor value="#{}">
<p:ajax />
</p:editor>
例如,这可以通过 p:inputText
找到,但是在编辑器中却出现此错误:
This works find for example with p:inputText
, but with the editor I get this error:
Unable to attach <p:ajax> to non-ClientBehaviorHolder parent
我还尝试将 onchange
属性添加到 p:editor
并调用 remoteCommand
提交内容,如下所示:>
I also tried adding the onchange
attribute to the p:editor
and calling a remoteCommand
to submit the content, like this:
<p:editor widgetVar="documentation" onchange="submitDocumentation" />
<p:remoteCommand name="submitDocumentation" process="@parent" update="@none" />
可以,但是每次击键都可以.我只想在焦点丢失时提交编辑器的内容.
That works, but on every single keystroke. I only want to submit the content of the editor when the focus is lost.
丢失焦点时是否可以使用Ajax提交Primefaces编辑器的内容?
Is it possible to use Ajax to submit the content of a Primefaces Editor when focus is lost?
使用Tomcat 7,Mojarra和Primefaces 4.0
Using Tomcat 7, Mojarra and Primefaces 4.0
推荐答案
您可以采用以下方式.
$(document).ready(function() {
//documentation is the editor widgetVar
PF('documentation').jq.find("iframe").contents().find('body').blur(function(){
submitDocumentation();//remoteCommand
});
});
这篇关于Primefaces编辑器和Ajax提交模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!