Reputation: 245
I have a very simple popup window with a rich editor:
<rich:modalPanel id="commentFormPanel" width="640" height="480">
<f:facet name="header">
<h:panelGroup>Comment</h:panelGroup>
</f:facet>
<h:form id="commentForm">
<rich:editor id="commentContent" width="620" height="440"
theme="simple" viewMode="visual"
value="#{commentHome.content}" />
</h:form>
</rich:modalPanel>
Is it possible to set focus in the rich:editor when the modal panel pops up?
Someone suggested to use this:
tinyMCE.execCommand('mceFocus',false,'commentForm:commentContent');
I tried but it did not work. Does anyone have a solution? Thanks.
Update:
I tried a few things:
a).
<rich:editor id="commentContent" width="620" height="440"
theme="simple" viewMode="visual">
<f:param name="auto_focus" value="commentForm:commentContent" />
</rich:editor>
b).
<rich:modalPanel onshow="tinyMCE.get('commentForm:commentContent').focus();">
both did not work.
Upvotes: 0
Views: 2101
Reputation: 26
This will work:
<rich:editor id="commentContent" width="620" height="440"
theme="simple" viewMode="visual" useSeamText="false"
value="#{commentHome.content}"
oninit="setTimeout( function() { tinyMCE.execCommand('mceFocus',false,'commentForm:commentContentTextArea'); }, 1);" />
Upvotes: 1
Reputation: 784
<rich:jQuery query="focus().select()" selector="#commentContent" name="focusInput"/>
<script>
focusInput();
</script>
Upvotes: 0