I am trying to open a VF page as a subtab through a commandButton opensubtab in the VF page ParentVF. While the subtab opens for the first time, but if the opened subtab is cancelled/closed and the opensubtab button is clicked again the ParentVF itself loads again.
JS:
<apex:includeScript value="/support/console/34.0/integration.js"/>
function openSTab(){
var tid;
var pg;
var cid ='{!case.id}';
if(sforce.console.isInConsole){
sforce.console.getEnclosingPrimaryTabId(fetchTabId);
}
function fetchTabId(result){
tid = result.id;
pg = '/apex/ChildPage?id='+cid;
sforce.console.getEnclosingTabId(openTab);
}
function openTab(result){
sforce.console.openSubtab(tid,pg,true,'test',null,undefined,'test');
}
}
VF:
<apex:commandButton onclick="openSTab()"/>
At times the subtab is not opening at all.