Yes, I see where is the problem here.
the EL in the reRender might be changed until the 6th phase during the Ajax Request. It makes it possible to decide what to re-render even in the action method on the 5th phase.
oncomplete is another story. It is pure client side behavior, so, i guess, the value is formed already before the Ajax Request
Important tip: do not use the local variable there if you expect they should be available from outside directly. When browser replaces the script the local-global issue takes place.
Example of local:
Example of global:
window.foo = bar;
I try it with a static JS function, rerender it and call inside the right JS method. This should work of course. I avoided it to define any JS inside a page so far.
Would it not be better to evaluate both attributes in the same phase? What's the benefit of doing it like it is currently?
Thanks for your help,
what is inside the oncomplete might not be evaluated on the same phase because it works on the client side not on the server side. So, we have to return the content of the oncomplete with ajax response and than evaluate.