demogorgorn / yii2-vex-dialog
为现代弹窗库Vex的Yii2包装器(https://github.com/HubSpot/vex)
dev-master
2017-10-04 19:31 UTC
Requires
- bower-asset/vex: *
This package is auto-updated.
Last update: 2024-09-21 21:21:57 UTC
README
为现代弹窗库Vex的Yii2包装器(https://github.com/HubSpot/vex)
安装
通过 composer 安装此扩展是首选方法。
运行以下命令
php composer.phar require --prefer-dist demogorgorn/yii2-vex-dialog "*"
或将以下内容添加到您的 composer.json
文件的require部分。
"demogorgorn/yii2-vex-dialog": "*"
例如:
使用方法
在你的视图文件中。
<?php VexAsset::register($this); VexThemeFlatAttackAsset::register($this); ?> <?php $js = 'function showModal() { vex.dialog.buttons.YES.text = "Yes!"; vex.dialog.buttons.NO.text = "No"; vex.dialog.confirm({ message: "Do you really want to visit Minsk, Belarus?", callback: function(value) { return console.log(value); }, className: "vex-theme-flat-attack" }); }'; $this->registerJs($js); ?>
之后,只需调用你的函数(在这个例子中是"showModal")。
例如,与 demogorgorn/yii2-ajax-submit-button(https://github.com/demogorgorn/yii2-ajax-submit-button)的常见使用
相同的视图文件
<?php \demogorgorn\ajax\AjaxSubmitButton::begin([ 'id' => 'delete-button', 'label' => Yii::t('modules/payments/common', 'Visit'), 'ajaxOptions' => [ 'type'=>'POST', 'url'=> \yii\helpers\Url::toRoute(['/payments/category/count-children']), 'beforeSend' => new \yii\web\JsExpression('function (xhr) { var idurl = getTreeSelectedItem(); if (idurl == null) { xhr.abort(); showModal(); } this.url = this.url + "&id=" + idurl; }'), 'success' => new \yii\web\JsExpression('function(html){ showModal(); }'), ], 'options' => ['class' => 'button large danger', 'type' => 'submit', 'disabled' => true], ]); \demogorgorn\ajax\AjaxSubmitButton::end(); ?>