Question

I have richfaces application. In the page, there is jQuery function defined:

<rich:jQuery timing="onJScall" name="updateUrlHash" selector="#conversationId" 
    query="alert('in jquery call');" />

Then I have some a4j:commandLink, which should call the function on completing ajax request.

<a4j:commandLink value="test" oncomplete="updateUrlHash(this)" />

Unfortunately, it does not work. I know oncomplete works, because if I put there alert('test');, alert is shown. But when I try to call updateUrlHash function, it does not work. I checked in page source that function is there. What can be wrong?

Was it helpful?

Solution

I found it. Query is called on object selected by jQuery selector. So in example like this, in javascript is it

jQuery(selector).alert('in jquery call');

This of course cannot work. So I need to call anything on selected element, and then I can do what I want:

query="hide(); alert('this works');"

In Javascript it is then (selected element is hidden anyway):

jQuery(selector).hide(); alert('this works');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top