2013-12-16 60 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

完美,這就是我想要的。謝謝! –