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
Irene SlessIrene Sless 

Rerender VF page block after @RemoteAction call

I have a VF page which lists a repeating block of data (a custom object). I can add a new object or delete one. When I add a new one the page displays the newly added object on return from the remote call. When I delete an object however, it does not seem to refresh the page and remove the deleted one.

How do I get it to refresh the page after having deleted something on the page?

This is what my page looks like. When I click on the 'Remove Call Cycle Event' button it runs the Javascript below the image, which calls the @RemoteAction in my controller. What do I need to do for it to remove the block I clicked the button on?
User-added image
In my VF page:
            jCC$(".remCCA").click(function() {
                var ccaId = this.id;
                if(ccaId != ''){
                    CallCycleController.RemoveCallCycleActivity(ccaId, function(result, event){
                        var foo = result;
                        alert('CallCycle Activity has been deleted');
                });
                return false;
            });

In my Controller:
  @RemoteAction
  public static void RemoveCallCycleActivity(string remId){
    CallCycleActivity__c delCCA = [Select Id, ActivityId__c From CallCycleActivity__c Where Id=:remId];
    delete delCCA; 
  }
Best Answer chosen by Irene Sless
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi Irene Sless,

Anyway once remoting is completed ,you have execution control in callback handler method so you can refresh yourpage like below code.
CallCycleController.RemoveCallCycleActivity(ccaId, function(result, event){
                        var foo = result;
                        alert('CallCycle Activity has been deleted');
                        window.location.reload();
                });

Let us know if it helps you.
Please refer these links as well.
https://www.salesforce.com/docs/developer/pages/Content/pages_charting_refreshing_data_javascript_remoting.htm

All Answers

Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi Irene Sless,

Anyway once remoting is completed ,you have execution control in callback handler method so you can refresh yourpage like below code.
CallCycleController.RemoveCallCycleActivity(ccaId, function(result, event){
                        var foo = result;
                        alert('CallCycle Activity has been deleted');
                        window.location.reload();
                });

Let us know if it helps you.
Please refer these links as well.
https://www.salesforce.com/docs/developer/pages/Content/pages_charting_refreshing_data_javascript_remoting.htm
This was selected as the best answer
Irene SlessIrene Sless
Thanks Ashish!
Fantastic! Yes it works. Can you tell me what the 'window.location' refers to? Is it the entire window or just the block from which the call came?
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi Irene Sless,

It refers the whole page.
Please mark it as solved and BEST ANSWER  if it helps you so others can get help for same issue.

 
nishad basha 7nishad basha 7
Hi, Ashish_Sharma_DEVSFDC

 how to change the labels in Account object using visualforce page. please give any ideas.
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi ,

Use below code to use label on page.
<apex:outputLabel value="Checkbox" for="theCheckbox"/>
<apex:inputCheckbox value="{!inputValue}" id="theCheckbox"/>

Let us know if it helps you.
Irene SlessIrene Sless
Ashish, could you tell me too if there is a way I reload only the repeating pageblock section in which my deleted item was?