How can I nicely to pre-load tab content before displaying tabs on the page? The tab content is another view with table and data loaded from DB using Zend controller. Basically, I want to avoid the first view, with showing some "loading ... " status, and showing the second view when it is ready.
I thought I can somehow do it from the module showing a message that data is loading, but I could not find a way to combine tabs and module.
Currently I have the following, and there is a significant delay between first and second page views:
**Tabs loaded, but tabs content is still loading **
Tabs loaded, and content loaded
The code is as the following:
View
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Index Tabs</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
</head>
<body>
<div id="tabs" style="width:100%">
<ul>
<li><a id="showform" href="<?php echo $this->url('OnlineFieldEvaluation',
array('action' => 'listforms', 'controller' => 'OnlineFieldEvaluation')); ?>">Forms</a></li>
<li><a id="showform" href="<?php echo $this->url('OnlineFieldEvaluation',
array('action' => 'editidentityinformation', 'controller' => 'OnlineFieldEvaluation')); ?>">Student Information</a></li>
</ul>
</div>
<script>
$('#tabs').css('width','auto');
$('#tabs').css('min-width','800px');
$('#tabs').css('position','absolute');
$("#tabs").tabs();
</script>
</body>
</html>
Controller:
public function listformsAction()
{
if ($this->zfcUserAuthentication()->hasIdentity()) {
$authorize = $this->getServiceLocator()->get('BjyAuthorize\Provider\Identity\ProviderInterface');
$roles = $authorize->getIdentityRoles();
$studentEvaluations = $this->getEntityManager()->getRepository('OnlineFieldEvaluation\Entity\StudentEvaluations')
->findBy(array('studEmail' => $this->zfcUserAuthentication()->getIdentity()->getEmail()));
$view = new ViewModel(array(
'evaluations' => $this->getEntityManager()->getRepository('OnlineFieldEvaluation\Entity\IdentityInformation')
->findBy(array('stud_email' => $this->zfcUserAuthentication()->getIdentity()->getEmail())),
'studentEvaluations' => $studentEvaluations,
'roles' => $roles
));
return $view;
} else {
return $this->redirect()->toRoute('zfcuser');
}
}
I found a solution here:
Zend Framework 2 display a view within a view
As per this zf2 documentaion page
Write this in login Action:
And in indexAction :
In index.phtml you can just echo login
where ever you want to display loginView.