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();
    //?>

    点击删除后:

  • 相关阅读:
    jqmodal遮罩层的实现
    让Editplus和SVN集成
    asp.net很有用的字符串操作类
    TCP socket编程
    Adroid: ProgressBar 的使用
    在想的事情......
    I'm new to CNBlogs!
    压力
    开心工作
    feature
  • 原文地址:https://www.cnblogs.com/ediszhao/p/5693212.html
Copyright © 2011-2022 走看看