小易 2018-12-11 11:28:01 2833次浏览 0条评论 3 1 0

看到现在的教程写个分页跳转搞这么复杂,把两年前写的yii2默认分页里加上跳转的功能分享下

看看效果

1.png

接下来看看很简单的代码,在生成curd中的index.php中添加,其中的location.href中引号中的字符串改成跳转的url

<?php
$script = <<< JS
    $(".pagination").append('&nbsp;跳转<input id="invalue" type="text" style="border-radius: 5px;outline: none;border: solid 1px #dddddd;width: 52px;height: 34px;text-align: center;" class="pane"/>页&nbsp;<button id="skip" class="btn btn-default skip ok"">确定</button>');
    
    $('#skip').click(function() {
        var page = $('#invalue').val();
        location.href = "index.php?r=region/index&page="+ page;
    });
JS;
$this->registerJs($script);
?>

如果要第一页跟尾页,在gridview中加上这两句

2.png

觉得很赞
    没有找到数据。
您需要登录后才可以评论。登录 | 立即注册