项目作者: Cenotia

项目描述 :
YII2 Remote Modal
高级语言: JavaScript
项目地址: git://github.com/Cenotia/yii2-remote-modal.git
创建时间: 2016-10-19T13:19:50Z
项目社区:https://github.com/Cenotia/yii2-remote-modal

开源协议:MIT License

下载


Yii2 Remote Modal

by cenotia

This extension enables the use of several types of modals in a simplify way and using ajax.

In order to add it to your project you have to download the archive or use the composer tool which is the preferred way.

In your composer.json file add the following line :

"cenotia/yii2-remote-modal":"*"

and run
composer update

In Controller

in your controller’s actions (that you want to display in a modal), add the following code :

  1. public function actionTest()
  2. {
  3. $request = \Yii::$app->request;
  4. \Yii::$app->response->format = Response::FORMAT_JSON;
  5. return [
  6. 'title'=> "Test Titre",
  7. 'content'=>"Test content", // for example: $this->renderAjax('view', [
  8. // 'model' => $model,
  9. // ]),
  10. 'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
  11. Html::button('Save',['class'=>'btn btn-primary','type'=>"submit"])
  12. ];
  13. }

In your view

At the beginning of your file

  1. use cenotia\components\modal\RemoteModal;

The calling link would be

<a href="/site/test" role="XXXXXXXXXID">Test</a>

At the end of the view file, add this :

  1. <?php RemoteModal::begin([
  2. "id"=>"XXXXXXXXXID",
  3. "options"=> [ "class"=>"fade slide-right "],
  4. "footer"=>"", // always need it for jquery plugin
  5. ])?>
  6. <?php RemoteModal::end(); ?>

The available classes in options are :

  • slide-right
  • stick-up
  • fill-in
  • slide-up