Benusko
Benusko

Reputation: 97

How to deactivate spellcheck in p:inputTextarea PrimeFaces?

I would like to deactivate the spell check in a PrimeFaces inputTextarea.

spellcheck="false" is not possible in a p:inputTextarea

<p:inputTextarea value="#{mybean.cardescription}" 
                 cols="95"
                 autoResize="true"
                 rows="20"/>

Upvotes: 6

Views: 1198

Answers (2)

Bj&#246;rn Zurmaar
Bj&#246;rn Zurmaar

Reputation: 829

Although I'm pretty late to the party I think there is a cleaner way to do it without Javascript. When you include the namespace xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" you can pass attributes through to the generated HTML and you can hence directly set the attribute in your JSF code:

<p:inputTextarea value="#{mybean.cardescription}" 
        cols="95"
        pt:spellcheck="false"
        autoResize="true"
        rows="20"/>

This works for all HTML attributes that do not have a corresponding JSF attribute in their components.

The pt is selected here to avoid namespace collisions with PrimeFaces. You'll also find p for passthrough attributes pretty often.

Upvotes: 1

kinkajou
kinkajou

Reputation: 3728

Use following:

<h:head>
    <h:outputScript   name="/js/util/disableSpellCheck.js"/> 
</h:head>

$('inputTextId').attr('spellcheck','false')

Upvotes: 1

Related Questions