unzoomed
unzoomed

Reputation: 580

Primefaces run java script onComplete/onClick

I have a p:command button as shown below.

<p:commandButton id="settings" ajax="false" onComplete="window.alert('sometext');"      value="#{messages.settings}"
styleClass="cancelButton" style="font-family: sans-serif, Arial, Helvetica, Geneva; font-size: 10pt; width: 90px;" /></td>

I want this button to run a java-script onComplete or onClick but I can not get any of them to work. I actually want it to open a popup but here I have tried with an easier script to just do an alert. But this does not work either. Nothing happens at all.

Can anyone help me?

Upvotes: 3

Views: 27930

Answers (1)

Daniel
Daniel

Reputation: 37061

First : there is no capitals in onxxx (where xxx is start / complete / success)

Since you set ajax="false" your button won't do any ajax , which means that onstart / oncomplete / onsuccess won't be triggered at all

Use onclick="alert('wow')"

If you will remove the ajax="false" you will be able to use oncomplete="alert('wow')"

Upvotes: 7

Related Questions