当前位置:编程学习 > JS >>

JS分页程序详解

/***************************************************/ 
      var pageFunc=function(){ 
        //alert('here'); 
        var _this=this; 
        this.render=function(arr){//模拟类的抽象函数 
            throw new Error('该函数不能为空'); 
            } 
        this.renderButton=function(){//模拟类的抽象函数 
            throw new Error('该函数不能为空'); 
            } 
        this.bindEvent=function(){//模拟类的抽象函数 
            throw new Error('该函数不能为空'); 
            } 
        this.init=function(){ 
            throw new Error('该函数不能为空'); 
            } 
        this.getChangePage=function(){ 
            throw new Error('该函数不能为空'); 
            } 
        this.getPages=function(){ 
            return 0; 
            } 
        this.pages=_this.getPages(); 
        this.currentPage=1; 
        this.pageSize=3; 
        this.getNextPage=function(){ 
            var _nextPage=_this.currentPage+1; 
            if(_nextPage>=_this.pages){ 
                    _nextPage=_this.pages; 
                } 
            return _nextPage; 
            } 
        this.getPreviousPage=function(){ 
            var _previousPage=1; 
            _previousPage=_this.currentPage-1; 
            if(_previousPage<=0){ 
                    _previousPage=1; 
                } 
            return _previousPage; 
            } 
        this.gotoPage=function(pageNum){ 
                if(pageNum!=_this.currentPage){ 
                    var _arr=''; 
                    _arr=[]; 
                    _arr['start']=pageNum-1; 
                    _arr['len']=_this.pageSize; 
                    _this.render(_arr); 
                    _this.currentPage=pageNum; 
                    _this.getChangePage(); 
                    //alert(pageNum); 
                } 
            } 
        this.gotoFirstPage=function(){ 
                //alert('gotoFirstPage'); 
                //alert(_arr['start']); 
                _this.gotoPage(1); 
            } 
        this.gotoLastPage=function(){ 
                _this.gotoPage(_this.pages);     
            } 
        this.gotoNextPage=function(){ 
            var _nextPage=_this.currentPage+1; 
            if(_nextPage>_this.pages){ 
                _nextPage=_this.pages; 
                } 
            _this.gotoPage(_nextPage); 
            } 
        this.gotoPreviousPage=function(){ 
            var _previousPage=_this.currentPage-1; 
            if(_previousPage<1){ 
                _previousPage=1 
                } 
            _this.gotoPage(_previousPage); 
            } 
        this.run=function(){ 
            _this.pages=_this.getPages(); 
      &nbs
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,