タブコントロールを持つjqueryモバイルサイトを1つ作成しましたが、最初にページを表示したときに機能しませんが、ページをリロードすると機能します。
また、リロードする前に動作するようにしたかった.....
ここにそのためのコード....
<?php
require_once"session.php";
require_once"getDetails.php";
$docId =$_GET['docId'];
$selDoc=$dbHandle->execQuery("SELECT * FROM master_doctor WHERE doctor_id='$docId'");
$fetDoc=$dbHandle->fetchObjectQuery($selDoc);
$qlfyVal='';
$qualId =explode(",",$fetDoc->qualification_id);
for($i=0;$i<sizeof($qualId);$i++)
{
$qlfyVal .=comnName('doc_qualification','name','qualification_id',$qualId[$i]).',';
}
$qlfyVal =substr($qlfyVal,0,strlen($qlfyVal)-1);
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $fetDoc->salutation.'.'.ucfirst($fetDoc->fname).ucfirst($fetDoc->lname).' '.$qlfyVal;?> Details</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php require_once"header.php";?>
<script type="text/javascript">
function ShowHide(id)
{
$('.datatab').each(function(){
if($(this).attr('id') != id)
{
$(this).hide();
}
else
{
$(this).show();
}
});
}
</script>
</head>
<body>
<div data-role="page" id="docView" >
<div data-role=header data-theme="e" >
<a href="doctorgrid.php" data-icon="back" ><font size="2px">back</font></a>
<h1 align="left"><font size="2px"><?php echo $fetDoc->salutation.'.'.ucfirst($fetDoc->fname).ucfirst($fetDoc->lname).' '.$qlfyVal;?> Details</font></h1>
</div>
<div data-role=content>
<div data-role="navbar">
<ul>
<li class="tabLi"><a onclick="ShowHide('contact')" class="ui-btn-active ui-state-persist">Contact</a></li>
<li class="tabLi"><a onclick="ShowHide('primary')">Primary</a></li>
<li class="tabLi"><a onclick="ShowHide('working')">Working</a></li>
</ul>
</div>
<div class="data-clear">
</div>
<div id="contact" class="datatab" >
<ul data-role=listview data-inset=true data-theme=d>
<li data-theme=e ><font size="2px"> Contact Info </font></li>
<li><font size="2px"> Phone No :
<?php
function ckVal($val,$ref)
{
$tmp="NA";
if($val != '')
{
if($ref == 'tel')
{
$tmp =',<a href="tel:'.$val.'">'.$val.'</a>';
}
else if($ref == 'mail')
{
$tmp =',<a href="mail:'.$val.'">'.$val.'</a>';
}
else
{
$tmp =','.$val;
}
}
return $tmp;
}
if($fetDoc->phone1!= '')
{
$ctNo ='<br/><a href="tel:'.$fetDoc->phone1.'">'.$fetDoc->phone1.'</a><br/>'.ckVal($fetDoc->phone2,'tel').'<br/>'.ckVal($fetDoc->mobile1,'tel').'<br/>'.ckVal($fetDoc->mobile2,'tel');
}
else
{
$ctNo ='<br/>'.ckVal($fetDoc->phone2,'tel').ckVal($fetDoc->mobile1,'tel').ckVal($fetDoc->mobile2,'tel');
}
echo $ctNo;
?></font></li>
<li><font size="2px"> Mail : <?php
if($fetDoc->official_email != '')
{
$ctMail ='<br/><a href="mail:'.$fetDoc->official_email.'">'.$fetDoc->official_email.'</a><br/>'.ckVal($fetDoc->personal_email,'mail');
}
else
{
$ctMail ='<br/>'.ckVal($fetDoc->personal_email,'mail');
}
echo $ctMail;?> </font></li>
<li><font size="2px"> Address : <?php
if($fetDoc->address1 != '')
{
$ctAddr ='<br/>'.$fetDoc->address1.'<br/>'.ckVal($fetDoc->address2,'');
}
else
{
$ctAddr ='<br/>'.ckVal($fetDoc->address2,'');
}
echo $ctAddr;?> </font></li>
</ul>
</div>
<div id="primary" class="datatab" style="display:none">
<ul data-role="listview" data-inset="true" data-theme="d" >
<li data-theme=e ><font size="2px"> Primary Info </font></li>
<li><font size="2px"> Specialization :
<?php
$splfyVal='';
$splfyId =explode(",",$fetDoc->specialization_id);
for($i=0;$i<sizeof($splfyId);$i++)
{
$splfyVal .=comnName('doc_specialization','name','specialization_id',$splfyId[$i]).',';
}
$splfyVal =substr($splfyVal,0,strlen($splfyVal)-1);
echo $splfyVal;
?>
</font></li>
<li><font size="2px"> Patients / day : <?php echo $fetDoc->ave_patients;?> </font></li>
<li><font size="2px"> Total RX Potental :
<?php
$slRx =$dbHandle->execQuery("SELECT SUM(mdcp.tot_potential * mp.mrp) as tot,SUM(mdcp.nrx * mp.mrp + mdcp.rrx * mp.mrp )/30 as Comptot,SUM((mdcp.nrx_qty - mdcp.nrx) * mp.mrp + (mdcp.rrx_qty - mdcp.rrx) * mp.mrp ) as Cmptot FROM master_doctor_cmpny_prod mdcp,master_product mp WHERE mdcp.doctor_id='$docId' AND mp.product_id=mdcp.product_id");
$fetRx =$dbHandle->fetchObjectQuery($slRx);
echo getCurrency().' '.$fetRx->tot .'/ month';
?>
</font></li>
<li><font size="2px"> Support for CHTND : <?php echo getCurrency().' '.round($fetRx->Comptot,2);?> </font></li>
<li><font size="2px"> Competitior Support : <?php echo getCurrency().' '.$fetRx->Cmptot;?> </font></li>
<li><font size="2px"> Last Visited : <?php
$toDy = date('Y-m-d H:i:s');
$lvq = $dbHandle->execQuery("select DATEDIFF('$toDy',saved_on) as dt from doctor_dcr where doctor_id='$docId'");
$lvf = $dbHandle->fetchObjectQuery($lvq);
if($lvf->dt != '')
{
if($lvf->dt > 0)
{
echo $lvf->dt.' Days ago';
}
}
else
{
echo 'NA';
}
?>
</font></li>
<li><font size="2px">Last 30 Days Ave Calls : <?php
$tDate=date("Y-m-d");
$toDate =strtotime ('-30 day',strtotime($tDate));
$toDate=date ('Y-m-j',$toDate);
$sCalls =$dbHandle->execQuery("SELECT * FROM doctor_dcr WHERE added_by='$usrId' AND flag='0' AND date(saved_on) BETWEEN '$toDate' AND '$tDate'");
$nmRows =$dbHandle->getNumRows($sCalls);
echo round($nmRows/30,2);
?>
</font></li>
<li><font size="2px"> Doctor Class : <?php echo $fetDoc->doc_class;?> </font></li>
</ul>
</div>
<div id="working" class="datatab" style="display:none">
<ul data-role=listview data-inset=true data-theme=d >
<li data-theme=e><font size="2px"> Working Info </font></li>
<?php
$tnt=0;
function workLocation($ref)
{
GLOBAL $dbHandle;
GLOBAL $docId;
$wlData="";
$h=0;
if($ref == 'hospital')
{
$slocDetails=$dbHandle->execQuery("SELECT hospital_id,hospital_name FROM doctor_hospital_link WHERE doctor_id='$docId'");
$getNR=$dbHandle->getNumRows($slocDetails);
if($getNR > 0)
{
while($fetDetails=$dbHandle->fetchObjectQuery($slocDetails))
{
$h++;
if($h < $getNR)
{
$wlData .='<a href="'.ROOT_PATH.'hospitalView.php?hospId='.$fetDetails->hospital_id.'">'.ucfirst($fetDetails->hospital_name).'</a>'.',';
}
else
{
$wlData .='<a href="'.ROOT_PATH.'hospitalView.php?hospId='.$fetDetails->hospital_id.'">'.ucfirst($fetDetails->hospital_name).'</a>';
}
}
}
else
{
$wlData="NA";
}
}
else if($ref == 'clinic')
{
$slocDetails=$dbHandle->execQuery("SELECT clinic_id,clinic_name FROM doctor_clinic_link WHERE doctor_id='$docId'");
$getNR=$dbHandle->getNumRows($slocDetails);
if($getNR > 0)
{
while($fetDetails=$dbHandle->fetchObjectQuery($slocDetails))
{
$h++;
if($h < $getNR)
{
$wlData .='<a href="'.ROOT_PATH.'clinicView.php?clinicId='.$fetDetails->clinic_id.'">'.ucfirst($fetDetails->clinic_name).'</a>'.',';
}
else
{
$wlData .='<a href="'.ROOT_PATH.'clinicView.php?clinicId='.$fetDetails->clinic_id.'">'.ucfirst($fetDetails->clinic_name).'</a>';
}
}
}
else
{
$wlData="NA";
}
}
else
{
$slocDetails=$dbHandle->execQuery("SELECT chemist_id,chemist_name FROM doctor_chemist_link WHERE doctor_id='$docId'");
$getNR=$dbHandle->getNumRows($slocDetails);
if($getNR > 0)
{
while($fetDetails=$dbHandle->fetchObjectQuery($slocDetails))
{
$h++;
if($h < $getNR)
{
$wlData .='<a href="'.ROOT_PATH.'chemistView.php?chemistId='.$fetDetails->chemist_id.'">'.ucfirst($fetDetails->chemist_name).'</a>'.',';
}
else
{
$wlData .='<a href="'.ROOT_PATH.'chemistView.php?chemistId='.$fetDetails->chemist_id.'">'.ucfirst($fetDetails->chemist_name).'</a>';
}
}
}
else
{
$wlData="NA";
}
}
return $wlData;
}
if(workLocation('hospital') != 'NA')
{
?>
<li><font size="2px"> Hospital Name : <?php echo workLocation('hospital');?></font></li>
<?php
}
else
{
$tnt++;
}
if(workLocation('clinic'))
{
?>
<li><font size="2px"> Clinic Name : <?php echo workLocation('clinic');?></font></li>
<?php
}
else
{
$tnt++;
}
if(workLocation('chemist'))
{
?>
<li><font size="2px"> Chemist Name : <?php echo workLocation('chemist');?></font></li>
<?php
}
else
{
$tnt++;
}
if($tnt == 3)
{
?>
<li><font size="2px"> NO Data To Display</font></li>
<?php
}
?>
</ul>
</div>
</div>
</body>
</html>
"header.php"
すべてのjsとcssに存在します