function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raghu RamanujamRaghu Ramanujam 

Rerender Visualpage after Remote Action

Hi guys,

I need some help in Renendering my VF to a particular Pageblock (or bottom of the page) after using @Remote Action.
Can you please help ?
This is my Controller:

public without sharing class RController1 {
  
   @RemoteAction
  Public static boolean saveSign(String signatureBody, id sobjId){
 
    try{
      Attachment sign = new Attachment();
      sign.parentId = sobjId;
      sign.Body =  EncodingUtil.base64Decode(signatureBody);
      sign.ContentType = 'image/png';
      sign.Name = 'Signature Capture.png';
        insert sign;
      
    }catch(Exception e){
        return false;
      
    return null;
  }


}

My Visualforce Page:

<apex:page standardController="Registration__c" extensions="RController1">

  function saveSign(){
        var strDataURI = canvas.toDataURL();
           console.log(strDataURI);
            strDataURI = strDataURI.replace(/^data:image\/(png|jpg);base64,/, "");
              console.log(strDataURI);
               RegistrationController1.saveSign(strDataURI,parentId,
                         function(result,event){
                                     if (event.status){ 
                                          rerendAction();  }
                                      else{ console.log(event.message); ) } }, {escape:true} );
}

<apex:actionFunction name="rerendAction" rerender="sign"/>
  <apex:pageBlockSection title="Signature" id="sign">
          <c:Signature parentId="{!$CurrentPage.parameters.Id}"/>
            <br />
              <apex:pageBlockSectionItem >
                   <apex:commandButton onclick="javascript:clearArea();return false;" onkeypress="" value="Clear Signature" style="width:60%" /> <apex:commandbutton id="sign" onclick="saveSign()" value="Submit Signature" style="width:60%" />
              </apex:pageBlockSectionItem> <br />
</apex:pageBlockSection>

Thanks,

Raghu

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Raghu Ramanujam,

May I suggest you please refer the below link to reference. Hope it helps.

Please mark it as best answer if the information is informative.

Thanks
Rahul Kumar
Raghu RamanujamRaghu Ramanujam
Hi Rahul,

Have tried that link, but its not working.
After the javascript Remoting the page reloads. I want the focus back to the block where the button was cllicked. ?

Thanks,
Raghu