5

I have a visualforce page that overrides the View on the Opportunity object. The VF page itself doesn't do a lot, however it has a controller that checks the state of the Opportunity and will redirect the user to another page in certain cases, such as based on Stage, etc. This is done via the action= attribute on the apex:page tag. This all works great when the Opp is viewed, or if the user clicks the [Edit] button to edit the Opportunity full screen, and then clicks [Save].

    <!-- Display the Main Opportunity Page -->
<apex:detail subject="{!Opportunity.Id}" rendered="{!Opportunity.Id != null}" relatedList="True" 
    showChatter="True" inlineEdit="true"  />

Where it breaks is when the user double-clicks on a field to use Inline Editing. After the user clicks [Save] in Inline Editing mode, the Opportunity detail section appears to be re-rendered (I'm assuming that because the content updates accordingly). However, in order for our custom logic to work, the page has to be completely reloaded after the Save so the controller can check he Opportunity Stage and take the necessary action.

I've tried a few different tricks to get the page to reload, but nothing has worked so far:

  • Add an "onComplete=" attribute to apex:detail. The documentation implies this gets run after the detail section re-renders, but I found that it did nothing.
  • Use jQuery to append JS to Salesforce's [Save] button. The onlick action on that button is easily retrievable via j$(".btn[name='inlineEditSave']").attr('onclick');, however adding window.reload(true); after the call to save() doesn't work either.

Has any one been able to successfully get the page to completely reload after inline editing completes?

  • OK, so after posting this and then going back to my page to test some other ideas I found that the "onComplete=" attribute on the apex:detail tag is working. Not sure why it didn't work initially, but it works now so all is good. – Force2b_Mike Sep 24 '14 at 11:48
8

Well, I've just tried the following code on my org with a newest Chrome and Firefox version and it reloads the entire page after save:

<apex:page standardController="Opportunity">

    <apex:detail subject="{!Opportunity.Id}" 
                 rendered="{!Opportunity.Id != null}" 
                 relatedList="True" 
                 showChatter="True" 
                 inlineEdit="true"
                 oncomplete="location.reload()"/>

</apex:page>
  • 1
    Agreed. I just added a comment on my original post noting that onComplete works. Odd that it didn't work initially, but so far I can't get it to not work again. Thanks for the quick response. – Force2b_Mike Sep 24 '14 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.