Reputation: 157
I have a button on the Case object that opens this visualforce page below. I want the window to close after save but I can't seem to get it to catch the close command. What it DOES do is when Save is clicked, the pages creates the record then refresh to page to present that record. I want it to save the record and close. Any ideas?
> <apex:page standardController="dingList__c">
<apex:form >
<apex:pageBlock title="{!$User.FirstName} reason's for re-queuing:">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" status="closer" rerender="buttons"/>
<apex:commandButton value="Cancel" onclick="window.top.close()"/>
<apex:actionStatus startText="(Saving...)" stopText="" onStop="window.top.close();" id="closer"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField id="reason" value="{!dingList__c.Reason__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Upvotes: 0
Views: 8589
Reputation: 16
Matthew, I think there is an easier way. You could do this: 1. Create an that calls the save method 2. Create a JS method that calls this action function, then calls close() on the window 3. In the onClick attribute call the JS method from point 2.
Voila ! :)
Upvotes: 0
Reputation: 7337
Create a Visualforce Page with this Markup:
<apex:page >
<script type="text/javascript">
window.close();
</script>
</apex:page>
Then, redirect (by JavaScript or Apex PageReference) to the page.
Upvotes: 1