'Set Primefaces inputText value from Javascript and have ajax fire

I have a primefaces(v10) input text which I need to set from a javascript function and also have an ajax event fire on blur. In my code I have this, but have been unsuccessful in getting the ajax function to fire.

<h:form id="myForm">    
    <p:inputText id="myText" widgetVar="myTextVar" value="#{myBean.myText}">
        <p:ajax event="blur" listener="#{myBean.updateMyText}"                                           update="myForm"/>
    </p:inputText>
</h:form>

I can set the inputText using:

document.getElementById("myForm:myText").value="The Value"

But I'm wondering if I need to use something from the PF() Widget API?



Solution 1:[1]

Its easy. Just use the widget...

PF('myTextVar').jq.val('The Value').trigger('change');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Melloware