cenotia / yii2-remote-modal
Yii2 远程模态
v1.0.3
2016-11-09 16:28 UTC
This package is not auto-updated.
Last update: 2024-09-20 19:55:40 UTC
README
# cenotia 的 Yii2 远程模态
此扩展允许以简化的方式使用多种类型的模态,并使用 AJAX。
要将它添加到项目中,您需要下载存档或使用 composer 工具,这是首选方式。
在您的 composer.json 文件中添加以下行
"cenotia/yii2-remote-modal":"*"
然后运行 composer update
### 在控制器中
在您的控制器动作(您想显示在模态中的动作)中添加以下代码
public function actionTest()
{
$request = \Yii::$app->request;
\Yii::$app->response->format = Response::FORMAT_JSON;
return [
'title'=> "Test Titre",
'content'=>"Test content", // for example: $this->renderAjax('view', [
// 'model' => $model,
// ]),
'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
Html::button('Save',['class'=>'btn btn-primary','type'=>"submit"])
];
}
在您的视图中
在文件开始处
use cenotia\components\modal\RemoteModal;
调用链接将是
<a href="/site/test" role="XXXXXXXXXID">测试</a>
在视图文件末尾添加以下内容
<?php RemoteModal::begin([
"id"=>"XXXXXXXXXID",
"options"=> [ "class"=>"fade slide-right "],
"footer"=>"", // always need it for jquery plugin
])?>
<?php RemoteModal::end(); ?>
在选项中可用的类包括
- slide-right
- stick-up
- fill-in
- slide-up