Skip to content

Latest commit

 

History

History
80 lines (66 loc) · 1.43 KB

README.md

File metadata and controls

80 lines (66 loc) · 1.43 KB

yii2-widgets

  • ButtonAjax make button with ajax for modal

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist prawee/yii2-widgets "*"

or add

"prawee/yii2-widgets": "*"

to the require section of your composer.json file.

Usage

1.ButtonAjax

on view dev-master

    use prawee\widgets\ButtonAjax;
    use yii\bootstrap\Modal;

    echo ButtonAjax::widget([
        'name'=>'Create',
        'route'=>['create'],
        'modalId'=>'#main-modal',
        'modalContent'=>'#main-content-modal',
        'options'=>[
            'class'=>'btn btn-success',
            'title'=>'Button for create application',
        ]
    ]);
    ....
    ....
    Modal::begin(['id'=>'main-modal']);
    echo '<div id="main-content-modal"></div>';
    Modal::end();

1.0

    echo ButtonAjax::widget([
        'title'=>'Create',
        'route'=>['create'],
    ]);

on controller

public functionn actionCreate(){
    .......
    .......
    if(Yii::$app->getRequest()->isAjax){
        return $this->renderAjax('create', [
            'model' => $model,
        ]);
    }else{
        return $this->render('create', [
            'model' => $model,
        ]);
    }
}

Update

2014-11-27 added indicator.gif and set $modalContent is null before load content.