Skip to content

Instantly share code, notes, and snippets.

@sfdcale
Last active December 15, 2019 03:08
Show Gist options
  • Select an option

  • Save sfdcale/20da03ec891e668a8b520da43c5570eb to your computer and use it in GitHub Desktop.

Select an option

Save sfdcale/20da03ec891e668a8b520da43c5570eb to your computer and use it in GitHub Desktop.
This is my approach of how to disable commandButton until first click is processed and re-enable after first click results are returned from controller to page.
<apex:page>
<script>
var defaultEventListenerForSubmitBtn;
</script>
<apex:outputPanel id="op-panel">
</apex:outputPanel>
<apex:commandButton value="Submit"
action="{!controllerActionMethod}"
rerender="op-panel"
onclick="this.value='Processing..';defaultEventListenerForSubmitBtn = this.onclick;this.onclick=function(){this.value='Processing..';return false;}"
oncomplete="this.onclick = defaultEventListenerForSubmitBtn;this.value='Submit';"/>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment