【问题标题】:Automatically set focus on p:editor on page load在页面加载时自动将焦点设置在 p:editor 上
【发布时间】:2013-04-15 13:41:29
【问题描述】:

如何在页面加载时自动将焦点设置在<p:editor>?

页面加载后,我希望能够在编辑器中进行书写,而无需额外点击编辑器面板。

【问题讨论】:

    标签: ajax jsf primefaces facelets


    【解决方案1】:

    Primefaces 提供属性“widgetVar”,因此您可以从客户端获取元素并聚焦它:

    <h:head>
            <script type="text/javascript">
                function test() {
                    xxx.focus();
                }
            </script>
        </h:head>
        <h:body onload="test()">        
            <h:form id="form">  
                <p:inputText id="rongnk" value="test"/>
                <p:editor widgetVar="xxx" id="nkrong" value="123" width="600"/>  
            </h:form>  
        </h:body>
    

    【讨论】:

      猜你喜欢
      • 2011-11-13
      • 2011-03-23
      • 2011-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-12
      • 1970-01-01
      相关资源
      最近更新 更多