This content has been marked as final.
Show 1 reply
-
1. Re: a4j:commandButton / a4j:commandLink 'onclick' attribute
sergeysmirnov Sep 19, 2007 1:58 PM (in response to alonsodomin)You confuse two different things.
onclick="a()" where function a() returns false
and
onclick="return a()"
are not the same things.
First Example:<div onclick="window.confirm('sure?');alert('you are sure!')" >Click Me</div>
The alert is shown always. Does not matter, what you click in the confirmation box.
Second example:<div onclick="return window.confirm('sure?');alert('you are sure!')" >Click Me</div>
The alert is not shown. Never. Just because, you say return in the first statement. Does not matter, what is returned. If JS interpretor sees a return, it stops the function and returns.
What you have in your case, is an equivalent of the second example. RichFaces puts your code in front of the ajax call. It tries to be hospitable :-)
What to do with the second example to make it workable like it is expected?
Try:<div onclick="if (! window.confirm('sure?')) { return false }; alert('you are sure!')" >Click Me</div>