Answer the question
In order to leave comments, you need to log in
How to use Pjax to partially refresh a page?
Welcome all.
There is an action
public function actionIndex($id = 1)
{
$employees = Employee::find()
->orderBy(['name' => SORT_ASC])
->all();
$emp = Employee::findOne($id);
return $this->render('index', [
'employees' => $employees,
'emp' => $emp
]);
}
<div class="site-index">
<div class="body-content">
<div class="row">
<div class="col-lg-2">
<p>
<?php foreach ($employees as $employee) {
echo "<a href=# onclick=\"$.pjax.reload('#pjaxId', {timeout : false});\">".$employee->name."</a><br /><br />";
}
?>
</p>
</div>
<div class="col-lg-9">
<?php Pjax::begin(['id' => 'pjaxId']);
echo $this->render('_view', ['emp' => $emp]);
Pjax::end(); ?>
</div>
</div>
</div>
</div>
<div class="employee-view" id="pjaxId">
<?= $emp->name; ?>
</div>
Answer the question
In order to leave comments, you need to log in
Well, firstly, send the designer back, let him cut off the trees from the background
border can be part of the background, why type it up? Well, or play around with layers. You can still stir up a beautiful parallax, if the forest is already a separate layer.
The problem is that in pjax.reload you use $employee->id as the ID of the Pjax container to be reloaded. Those. in fact, now you have one container with the identifier $emp->id, and when forming links, you specify the identifiers of containers that do not exist at all. Why do you use $emp->id as the identifier of the Pjax container, what is the sacred meaning? Just set the container id to a constant value, for example
, and when pjax.reload use it, not $employee->id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question