walkboy/yii2-ajax-progress-bar

为yii2设计的带有通过Ajax更新功能的Bootstrap进度条小部件

dev-master 2022-03-03 11:15 UTC

This package is auto-updated.

Last update: 2024-09-29 05:22:32 UTC


README

Bootstrap 4进度条小部件,可以通过周期性的Ajax请求更新百分比值。

安装

composer require walkboy/yii2-ajax-progress-bar:dev-master

使用方法

在您的视图中

<?= \walkboy\ProgressBar\ProgressBar::widget([
    'bars' => [
        [
            'percent' => $model->progressPercent, // initial percent
            'label' => $model->progressPercent.'&thinsp;%', // initial label
            'options' => ['class' => 'progress-bar-primary progress-bar-animated progress-bar-striped'],
        ],
    ],
    'url' => ['controller/some-progress', 'id' => $model->id],
    // 'period' => '10', // how often update request will be send (default 5 sec)
]) ?>

在您的控制器中

function actionSomeProgress($id)
{
    $model = $this->findModel($id);
    return [
        'percent' => $model->progressPercent,
        'label' => $model->progressPercent.'&thinsp;%',
    ];
}