zoukankan      html  css  js  c++  java
  • YIi2 Pjax简单使用

    1.点击事件需要在Pjax::begin() 和Pjax::end()范围内

    2.需要在链接配置数组后加上  ['data-pjax'=>'#testPjax'] 其中,'#testPjax‘是页面的id

    3.后台Action:return renderAjax('xxx');

    test.php

    <?php
    Pjax::begin(['id'=>'testPjax']);
    echo yiigridGridView::widget([
        'dataProvider' => $provider,
        'emptyText'=>'can not get anything from server!!!!',
        'columns' => [
            ['class' => 'yiigridCheckboxColumn'],
            'name',
            'password',
            ['label'=>'测试新增列->name','value'=>'name'],
            [
                'class'=>'yiigridActionColumn',
                'header'=>'操作',
                'template'=>'{view}{delete}{update}',
                'buttons'=>[
                    'delete'=>function ($url,$model,$key){
                        return Html::a('<i class="glyphicon glyphicon-trash"></i>',
                            ['del', 'id' => $key],
                            ['data-pjax'=>'#testPjax'],
                            [
                                //'class' => 'btn btn-default btn-xs',
                                'data' => ['confirm' => '你确定要删除文章吗?',]
                            ]
                        );
                    },
                ],
            ],
        ],
    ]);
    
    Pjax::end();
    ?>

    后台Action:

    public function actionDel($id=null,$name=null)
        {
            //echo $id;
            return $this->renderAjax('show',['data'=>$id]);
        }

    show.php:

    <?php
    //Pjax::begin(['id'=>'testPjax']);
    if (isset($data))
    {
        echo "<h1>测试Pjax成功! delete id :".$data."</h1>";
    }
    //Pjax::begin(['id'=>'testPjax']);
    //echo $data;
    //Pjax::end();
    //?>

    点击删除后:

  • 相关阅读:
    Queue——C#浅谈
    C#设计模式(7)——适配器模式
    test
    python 技巧
    在centos 配置python django环境 总结
    pyqt5 做的小程序,可以用来UI做个小demo
    python sqlalthemy 总结
    数据清理,预处理 pandas dataframe 操作技巧 总结
    对区块链看法
    hadoop spark 总结
  • 原文地址:https://www.cnblogs.com/ediszhao/p/5693212.html
Copyright © 2011-2022 走看看