2013-12-16 65 views
1

我的页面上有一个Primefaces编辑器,当用户关注页面上的其他组件时,我想将内容提交到服务器。Primefaces编辑器和ajax模糊提交

<p:editor value="#{}"> 
    <p:ajax /> 
</p:editor> 

这工作找到例如与p:inputText,但与编辑,我得到这个错误:

Unable to attach <p:ajax> to non-ClientBehaviorHolder parent 

我也尝试添加了onchange属性为p:editor和调用remoteCommand提交的内容,像这样:

<p:editor widgetVar="documentation" onchange="submitDocumentation" /> 
<p:remoteCommand name="submitDocumentation" process="@parent" update="@none" /> 

这有效,但在每一个按键。我只想在焦点丢失时提交编辑器的内容。

焦点丢失时,是否可以使用Ajax提交Primefaces编辑器的内容?

使用Tomcat 7,钻嘴鱼科和Primefaces 4.0

回答

3

您可以在接下来的方式做到这一点。

$(document).ready(function() { 
    //documentation is the editor widgetVar 
    PF('documentation').jq.find("iframe").contents().find('body').blur(function(){ 
     submitDocumentation();//remoteCommand 
    }); 
}); 
+0

完美,这就是我想要的。谢谢! –