gpt4 book ai didi

jsf-2 - p :editor Primefaces 的剩余字符

转载 作者:行者123 更新时间:2023-12-04 22:47:54 26 4
gpt4 key购买 nike

我知道 Primefaces 为 p:inputTextarea 的剩余字符提供了功能,如下面的代码所示

<p:inputTextarea rows="1" cols="85" counter="counter" maxlength="100" counterTemplate="{0} characters remaining" value="#{managedBean.inputvalue}" ></p:inputTextarea>
<h:outputText />
<h:outputText id="counter" />

但我想在 p:editor 中做同样的事情。怎么做? primefaces 是否提供了这样的功能,还是我必须通过其他方式来实现这一点{比如编码这个功能}。

TIA

最佳答案

<p:editor没有选择,你可以使用jquery来解决这个问题。我的解决方案是将 keyup 事件绑定(bind)到您的编辑器
我刚刚测试过,我的例子有一种形式(id:fm),一种编辑器(id:rongnk),一种输出文本(id:txt):

<h:body onload="bindiframe()">
<h:form id="fm">
<p:editor id="rongnk" value="xxx">
</p:editor>
<h:outputText id="txt"/>
<script type="text/javascript">
var imax = 50;
function bindiframe(){
$('#fm\\:rongnk').find('iframe').contents().find("body").on('keyup', function(e) {
ilength = $('#fm\\:rongnk').find('iframe').contents().find("body").text().length;
$('#fm\\:txt').html('Remain:' + (imax - ilength));
});
}
</script>
</h:form>
</h:body>

关于jsf-2 - p :editor Primefaces 的剩余字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16459366/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com