+ Start a Discussion
Neil KimNeil Kim 

With Apex:actionfunction, jquery stop.

Hi all.
I have jquery-html code that work well out of SFDC.
Now I'm trying to move it to SFDC VF.

Currently, without action, jquery works well. However, when I add Actionfunction, it stoped.
I will show you code.

Jquery
<script> 
// Slide Up
$(document).ready(function(){
    $("#btn2").click(function(){
        $("#last").slideUp("slow");
      $("#end").show();
       });
  });
</script>

VF
<apex:form>
	<apex:actionFunction name="runSave" action="{!saveResponse}"/>
  </apex:form>
  	<button class="btn	btn-primary	btn-block" id="btn2" onclick="runSave()"> Submit </button>

I cannot use Command Button because, Command Button does not accept jquery using id("btn2").
When I use commandbutton instead of button, it doesn't work.

But I need to run method in Controller, so I tried to use actionfunction.
However, when I run above code, slide up work at the first time and during sliding, page reloaded and slidnig cannot be completed.
I need to complete sliding and stop at div section sliding up completed.

Anybody help me approach?

Thanks in advance.
 
Rohit saini 4Rohit saini 4
Hi Neil,

You need to add rerender attribute on actionFunction which is used to make partial page refresh. Without Rerender attribute, system reload whole page which is why sliding is not being completed.
If you don't want anything to update on page after actionFunction, put anything in Rerender (like rerender="nothing").
If you want particular section(s) to refresh, you can put comma seperated Ids so that it only refreshes those sections on page. For more information please go through : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionFunction.htm

Thanks.