Heim > Web-Frontend > js-Tutorial > Hauptteil

jquery-Implementierung des Pager-Steuerelements example_jquery

WBOY
Freigeben: 2016-05-16 16:52:53
Original
1373 Leute haben es durchsucht

js:

Code kopieren Der Code lautet wie folgt:

$.fn.extend({ JPager: function (cfg, pageIndex, pageSize) {
    if (cfg && pageIndex > 0 && pageSize>0) {
        var token = "#" this.attr("id");
        this.empty();
        var pageFirst = function () {
            $(token).JPager(cfg, 1, pageSize);
        };

        var pagePre = function () {
            $(token).JPager(cfg, pageIndex - 1, pageSize);
        };

        var pageLast = function () {
            $(token).JPager(cfg, parseInt($("#_tot").val()), pageSize);
        };

        var pageNext = function () {
            $(token).JPager(cfg, pageIndex 1, pageSize);
        };
this).text()), pageSize);
        };

        var pageGo = function () {
            var index = parseInt($("#_pos").val());
            var total = parseInt($("#_tot").val());
            if (index) {
               if (index > total) {
                  ).JPager( cfg, total, pageSize);
                }
                else if (index < 1) {
                    $(token).JPager(cfg, 1, pageSize);
              (token).JPager(cfg, index, pageSize);
                }
            }
        };
        var checkGoNumber = function () {
            if (!Number(this.value)) {
                this.value = "";
            }
else {
                this.value = Number(this.value);
            }
        };
        var initCustomer = function (recordCount) {
            if (cfg.customer) {
               if (cfg.customer.template) {
                    var t =. vgl g.customer.template;
                    t = t.replace(/%total%/gi, Math.ceil(recordCount / pageSize)).replace(/%current%/gi, pageIndex).replace(/%recordCount%/gi, recordCount).replace(/% pageSize%/gi, pageSize);
                   if (cfg.customer.position == "right") {
                      $("#_right").after(t);
        >                    sonst {
                        $("#_left").before(t);
                    }
                
        var changeState = function (total) {
if (pageIndex == 1) {
                $("#_first").attr("class", "unable");
                $("#_pre").attr("class", "unable" ) ").bind("click", pagePre).attr("class", "number");
            }
            if (pageIndex == total) {
                $("#_last").attr ("class", "unable") ).bind("click", pageLast).attr("class", "number");
                $("#_next").bind("click", pageNext).attr("class", "number ");
            }
        };
        var initNumber = function (total, count, current) {
            if (total > 0 && count > 0). 🎜>                    aktuell = Gesamt;
                }
                var endIndex = gesamt;
                var startIndex = 1; {
                    if (temp < ; count) {
                       endIndex = count;
                       startIndex = temp - count 1;
                        endIndex = temp;
                    }
                
                   if (total > count) {
                       startIndex = total - count. 1;
                   }
                $("#_number").empt();
                für (var i = startIndex; i <= endIndex; i ) {
                   var html = $("").text(i).bind("click", pageNumber);
                   if (i == current) {
                       $("#_number").append(html.attr("class", "selected"));
                               else {
                        $( "#_number").append(html.attr("class", "number"));
                    ;

        var initPager = function (data) {
            if ($.isArray(data.SearchResult) && data.RecordCount > 0) {
                $(token).append("< span id='_left'>首页  上一页  < input id='_to' type='button' value='GO'/>  下一页  末页 ");
                var total = Math.ceil(data.RecordCount / pageSize);
                $("#_tot").val(total);
                $("#_pos").bind(" Blur", checkGoNumber);
                $("#_to").bind("click", pageGo);

                changeState(total);
                if (cfg.showNumber && cfg.count > ; 0) {
                   initNumber(total, cfg.count, pageIndex);
               }
        };

        if (cfg .action) {
            if (cfg.action.url && cfg.action.data) {
                var d = cfg.action.data.substr(0, cfg.action.data.lastIndexOf("}") ) ',"pageIndex":' pageIndex ',"pageSize":' pageSize "}";
                if (cfg.action.callback && $.isFunction(cfg.action.callback)) {
                    $.ajax ({
                       Typ: „Beitrag“,
                       URL: cfg.action.url,
                       Datentyp: „json“,                        Daten: d,
                        Erfolg: Funktion (Daten) {
                            initPager(data.d); .callback(data.d);
                        
                                                                      URL: cfg.action.url,
dataType: „json“,
contentType: „text/json“,
Daten: d,
Erfolg: Funktion (Daten) {
initPager(data.d);
               
css:




Code kopieren


Der Code lautet wie folgt:

#_pos { Breite: 40 Pixel;

Farbe:# 0000FF;
Textdekoration: Unterstreichung;

;} html:


Code kopieren


Der Code lautet wie folgt:





Beispiel für Seitensteuerung



Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage