What I'm trying to do is have an Apex command button that on the click opens a new VF page and also, have an action that does some backend query to get data ready for the popup VF page.
Not sure why this isn't working. Anyways, here's my code :
These next two blocks of code are located on the same VF page FYI :
<apex:outputPanel>
<apex:inputText required="true" label="Source"/>
<!--<input type="button" onclick="openPopup()" value="open popup"/>-->
<apex:commandButton value="open popup" onclick="openPopup()" action="{!executeQuery}"/>
</apex:outputPanel>
<script type="text/javascript">
var newWindow = null;
function openPopup() {
newWindow = window.open('OMTCustomPage2', 'Popup', 'height=500, width=500');
}
function closePopup(object,name) {
if(newWindow!=null)
newWindow.close();
}
</script>
And this is in the 2nd VF page which is the popup :
<script type="text/javascript">
var newWindow = null;
function openPopup() {
newWindow = window.open('OMTCustomPage2', 'Popup', 'height=500, width=500');
}
function closePopup(object,name) {
if(newWindow!=null)
newWindow.close();
}
</script>