• Sankkyy
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I have an apex command button as below calling a custom controller method

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="this.disabled=true;"/>

 

The method saves the item and navigate to another page. It is not a partial page update call.

 

I would like to disable button after the first click. I tried using onclick and calling a javascript to set the disabled status as true. When I use onclick even to make the javascript call, the button becomes disabled, but the save method on the controller is not being called.

 

I changed the button onclick event  to just alert 'hi' as below and it works. It alerts and then also makes the method call

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="alert('hi');"/> 

 

But when I added the code to disable the button too as shown below, it stops calling the controller method.

 

<apex:commandButton value="Add Item(s)" id="addItem" action="{!addItems}" onclick="alert('hi');this.disabled=true;"/>

 

Is there a different way to solve this?

Message Edited by DCS on 05-07-2009 02:03 PM
  • May 07, 2009
  • Like
  • 0