1

I have a custom visualforce page which over-rides the standard "view" of the record for a customObject__c. It looks like this.

<apex:page standardController="customObject__c" showHeader="true" sidebar="true">

<apex:sectionHeader title="customObject" subtitle="My Custom Name" id="test"/> 

<!-- Chatter feed-->
<chatter:feedWithFollowers entityId="{!customObject__c.Id}" showHeader="true"/>

<apex:detail subject="{!customObject__c.Id}" relatedList="true" inlineEdit="true" title="false"/>

Simple and straight forward. I used the section header tag explicitly becuase I need to change the subTitle and its css Style dynamically depending on field on customObject. When the user edit the page "inline", standard Save action on detail tag is not refreshing the entire page except that tag area.

How should I achieve refreshing the entire page not just the detail tag area on standard save action? something from javascript?......

Thanks in Advance.

2 Answers 2

2

Use this jquery code to reload the page. Also don't forgot to include jQuery.

$('#btn').ajaxComplete(function() {
  location.reload();
});

in place of #btn replace this with Save button id or class name. This is a type of JavaScript hack so not sure how much time it will work but for now it will help you.

update: You can also use this thanks to @Crop

$( "input[name='Save']" ).ajaxComplete(function() {
      location.reload();
    });
9
  • is it top.location or location will work?
    – Ratan Paul
    Dec 3, 2015 at 17:09
  • location will work. top.location is needed when we are using inner VF page in some detail page. Dec 3, 2015 at 17:11
  • @TusharSharma Every button on the detail page has same css class 'btn'. Is there any work-around for this? because we did not want users to reload for every button click that has ".btn" class.
    – sam_s
    Dec 3, 2015 at 17:24
  • The answer calls for the ID of btn (#btn) not the class (.btn). You should be fine Dec 3, 2015 at 17:31
  • 1
    Can you use this jQuery selector instead: $( "input[name='Save']" ).ajaxComplete(...) ? See api.jquery.com/attribute-equals-selector
    – cropredy
    Dec 3, 2015 at 18:23
0

Took a while, but I figured out a way to do this. Here is my answer.

I used the apex:actionFunction tag to achieve this.

<apex:form>

       <!--Here the action function re-renders 
       the outputpanel/sectionHeader for every on-complete 
       event of detail tag-->

    <apex:actionFunction name="callSecHeader" reRender="customObjSectionHeaderPanel" />
    <apex:outputPanel id="customObjSectionHeaderPanel">
        <apex:sectionHeader title="customObject" subtitle="My Custom Name"/>
    </apex:outputPanel>
</apex:form>


<apex:detail subject="{!customObject__c.Id}" relatedList="true" inlineEdit="true" title="false" oncomplete="callSecHeader();"/>
1
  • Though this do not answer the question exactly (refreshing the whole page on "save" action) but it does the work that I need.
    – sam_s
    Dec 4, 2015 at 15:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .