在页面加载时自动在p:editor上设置焦点

时间:2022-10-25 20:01:28

How do I automatically set the focus on <p:editor> on page load?

如何在页面加载时自动将焦点设置在 上?

After page is loaded I would like to be able to write in the editor without an additional click on the editor panel.

页面加载后,我希望能够在编辑器中编写,而无需在编辑器面板上单击。

1 个解决方案

#1


3  

Primefaces provide attribute 'widgetVar', so you can get element from client and focus it:

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>

#1


3  

Primefaces provide attribute 'widgetVar', so you can get element from client and focus it:

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>