I’m using
<apex:actionFunction>
and my page is reloaded. I don’t usereRender
attribute and I’m wondering if there is a way to prevent page reloading.Maybe there is a special value to set to
reRender
?EDIT :
Here is my code :
<apex:page controller="myController"> <apex:commandButton value="save" onclick="save()"/> <script type="text/javascript"> function save(){ // Some code myMethod('param'); // Some code } </script> <apex:form > <apex:messages /> <apex:actionFunction name="myMethod" action="{!controllerMethod}"> <apex:param name="param" value="" /> </apex:actionFunction> </apex:form> </apex:page>
And my controller :
public String controllerMethod() { String values = Apexpages.currentPage().getParameters().get('param'); system.debug('Values : ' + values); return values; }
Answer
If you call the action function just put return false;
to the end of the call:
<apex:actionFunction name="myFunction" action="{!someMethod}" />
<a href="#" onclick="myFunction(); return false;">Click me</a>
Or based on your code:
<apex:commandButton value="save" onclick="save(); return false;"/>
Attribution
Source : Link , Question Author : SF_user , Answer Author : Sergej Utko