0

I am using apex:form and using apex:commandbutton is not allowing to use fontawesome icon inside that button. So, I want to create a button which will onClick call the apex:actionFunction and will submit that form.

Is it possible to submit the form using apex:actionfunction only not by apex:commandButton? If so, how?

2

Yes, you can do this, just make sure you cancel the default action:

<apex:actionFunction name="doAction" action="{!someMethod}" />
<button onclick="doAction(); return false;">Do Action!</button>

If you don't include a reRender attribute, it behaves mostly like a normal full-form submit, but if you do, it does a partial update of the page. The apex:actionFunction should be within the apex:form you wish to submit.

  • I tried using the above it worked for me, but whenever I click the button it is refreshing the whole page, how we can prevent it. In my case I have a form with input elements and using a button I want to call that action function which will make the request to controller, and if it is completed I have to reRender a specific outputPanel. But unfortunately it is refreshing the whole page and reRender is not working for the same, Please suggest a better way to achieve this scenario. It will be very helpful to me. Thanks, – Prateek Kumar Feb 20 '18 at 6:56
  • @PrateekKumar the reRender should work. Make sure you're cancelling the default form submit. – sfdcfox Feb 20 '18 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.