[英]Yii2: How to render two views at the same time?
我有_form視圖,帶有一個執行actionCreate()函數的提交按鈕:
<?= Html::submitButton() ?>
按下時,必須渲染/重定向兩個視圖:
這是簡化的actionCreate()函數:
public function actionCreate() {
$model = new Persons();
$this->render('_rpficha', [ 'model' => $model]);
return $this->redirect(['index', 'id' => $model->id]);
}
您需要將JavaScript用於此類客戶端操作。
在您的view / index.php文件中:
<?php
$this->registerJs('
setTimeout(function () {
window.location.href = "http://www.google.com"
}, 5000); //5 seconds timeout. set it to 0, if you want to do it immediately',
\yii\web\View::POS_READY);
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.