karnbrockgmbh/yii2-modal-ajax
Composer 安装命令:
composer require karnbrockgmbh/yii2-modal-ajax
包简介
A wrapper around Yii2 Bootstrap Modal for using an ActiveForm via AJAX inside
关键字:
README 文档
README
A wrapper around Yii2 Bootstrap Modal for using an ActiveForm via AJAX inside.
Installation
The preferred way to install this extension is through composer.
Either run
$ php composer.phar require --prefer-dist karnbrockgmbh/yii2-modal-ajax "@dev"
or add
"karnbrockgmbh/yii2-modal-ajax": "@dev"
to the require section of your composer.json file.
Usage
Controller
Extend your basic logic with ajax render and save capabilities:
<?php public function actionCreate() { $model = new Company(); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('create', [ 'model' => $model, ]); }
to
<?php public function actionCreate() { $model = new Company(); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { if (Yii::$app->request->isAjax) { // JSON response is expected in case of successful save Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['success' => true]; } return $this->redirect(['view', 'id' => $model->id]); } } if (Yii::$app->request->isAjax) { return $this->renderAjax('create', [ 'model' => $model, ]); } else { return $this->render('create', [ 'model' => $model, ]); } }
View
<?php use karnbrockgmbh\modal\Modal; Modal::begin([ 'id' => 'createCompany', 'url' => Url::to(['/partner/default/create']), // Ajax view with form to load 'ajaxSubmit' => true, // Submit the contained form as ajax, true by default // ... any other yii2 bootstrap modal option you need ]); Modal::end();
Plugin Events
On top if the basic twitter bootstrap modal events the following events are triggered
kbModalBeforeShow
This event is triggered right before the view for the form is loaded. Additional parameters available with this event are:
xhr: XMLHttpRequest, the jQuery XML Http Request object used for this transaction.settings: object, the jQuery ajax settings for this transaction.
$('#createCompany').on('kbModalBeforeShow', function(event, xhr, settings) { console.log('kbModalBeforeShow'); });
kbModalShow
This event is triggered after the view for the form is successful loaded. Additional parameters available with this event are:
data: object, the data object sent via server's response.status: string, the jQuery AJAX success text status.xhr: XMLHttpRequest, the jQuery XML Http Request object used for this transaction.
$('#createCompany').on('kbModalShow', function(event, data, status, xhr) { console.log('kbModalShow'); });
kbModalBeforeSubmit
This event is triggered right before the form is submitted. Additional parameters available with this event are:
xhr: XMLHttpRequest, the jQuery XML Http Request object used for this transaction.settings: object, the jQuery ajax settings for this transaction.
$('#createCompany').on('kbModalBeforeSubmit', function(event, xhr, settings) { console.log('kbModalBeforeSubmit'); });
kbModalSubmit
This event is triggered after the form is successful submitted. Additional parameters available with this event are:
data: object, the data object sent via server's response.status: string, the jQuery AJAX success text status.xhr: XMLHttpRequest, the jQuery XML Http Request object used for this transaction.
$('#createCompany').on('kbModalSubmit', function(event, data, status, xhr) { console.log('kbModalSubmit'); // You may call pjax reloads here });
karnbrockgmbh/yii2-modal-ajax 适用场景与选型建议
karnbrockgmbh/yii2-modal-ajax 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 5.98k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2015 年 12 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bootstrap」 「modal」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 karnbrockgmbh/yii2-modal-ajax 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 karnbrockgmbh/yii2-modal-ajax 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 karnbrockgmbh/yii2-modal-ajax 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Fork from ghosh/Micromodal. Tiny, dependency-free javascript library for creating accessible modal dialogs.
Make Filament modals draggable.
A Filament form component that displays repeater items in a table with modal-based editing.
A Laravel Nova field. To create a modal for creating or viewing related HasMany records without leaving the index page
统计信息
- 总下载量: 5.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-08