IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Comment utiliser le plugin easyPaginate.js plusieurs fois sur la même page ?


Sujet :

jQuery

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2012
    Messages
    47
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Décembre 2012
    Messages : 47
    Points : 33
    Points
    33
    Par défaut Comment utiliser le plugin easyPaginate.js plusieurs fois sur la même page ?
    bonjour,
    j'ai un problèm depuis un certain temps au niveau du plugin easyPaginate.js que je n'ai pas réussi a en trouver une sollution.(voir photo en dessous)

    tout simplement a chaque fois que j'éxecute le plugin, la valeur de la page courrante s'incrémente automatiquement +1, j'ai besoin d'utiliser le plugin pour : pagination initiale(chargement de la page), pagination au moment du trie, pagination au moment de l'écriture dans la zone de texte de recherche.

    voila le plugin :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
     
    // JavaScript Document
    /*
    * jQuery easyShare plugin
    * Update on 28 december 2011
    * Version 1.0
    *
    * Licensed under GPL <http://en.wikipedia.org/wiki/GNU_General_Public_License>
    * Copyright (c) 2008, Stéphane Litou <contact@mushtitude.com>
    * All rights reserved.
    *
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.
     
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
     
        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */
     
    (function ($) {
        var displayPage = 0, defaults = "", plugin, displayNav, getNbOfPages, transition_default, transition_fade;
        var transition_slide, transition_climb;
        $.fn.easyPaginate = function (options) {
            defaults = {
                paginateElement: 'span',
                hashPage: 'page',
                elementsPerPage: 3,
                effect: 'default',
                slideOffset: 200,
                firstButton: true,
                firstButtonText: '<<',
                lastButton: true,
                lastButtonText: '>>',
                prevButton: true,
                prevButtonText: '<',
                nextButton: true,
                nextButtonText: '>',
                onSomeEvent: function () { }
            }
     
            return this.each(function () {
     
                plugin = Object;
                plugin.el = $(this);
                if ($('.easyPaginateList').length > 0) {
                    plugin.el.removeClass('easyPaginateList');
                    plugin.el.addClass('easyPaginateList');
                }
                else if ($('.easyPaginateList').length == 0) {
                    plugin.el.addClass('easyPaginateList');
                }
     
                plugin.settings = {
                    pages: 0,
                    objElements: Object,
                    currentPage: 1
                }
     
                getNbOfPages = function () {
                    return Math.ceil(plugin.settings.objElements.length / plugin.settings.elementsPerPage);
                };
     
                displayNav = function () {
                    htmlNav = '<div class="easyPaginateNav" style="text-align:left;position:absolute;margin-top:39em;margin-right:50em;">';
     
                    if (plugin.settings.firstButton) {
                        htmlNav += '<a href="#' + plugin.settings.hashPage + ':1" title="Premiere page" rel="1" class="first">' + plugin.settings.firstButtonText + '</a>';
                    }
     
                    if (plugin.settings.prevButton) {
                        htmlNav += '<a href="" title="Precedent" rel="" class="prev">' + plugin.settings.prevButtonText + '</a>';
                    }
                    for (i = 1; i <= plugin.settings.pages; i++) {
                        htmlNav += '<a href="#' + plugin.settings.hashPage + ':' + i + '" title="Page ' + i +
                             '" rel="' + i + '" class="page">' + i + '</a>';
                    }
     
                    if (plugin.settings.nextButton) {
                        //  $("a.page").attr("rel").remove();
                        htmlNav += '<a  title="Suivant" rel="' + parseInt(plugin.settings.currentPage + 1) + '" class="next">' + plugin.settings.nextButtonText + '</a>';
                    }
     
                    if (plugin.settings.lastButton) {
                        htmlNav += '<a href="#' + plugin.settings.hashPage + ':' + plugin.settings.pages + '" title="Dernière page" rel="' + plugin.settings.pages + '" class="last">' + plugin.settings.lastButtonText + '</a>';
                    }
     
                    htmlNav += '</div>';
                    plugin.nav = $(htmlNav);
                    plugin.nav.css({
                        'align': 'center',
                        'width': plugin.el.width() / 4, //<== largeur de la dive de pagination
                        'margin-left': 'auto'
                        //'margin-top':40
                        //,'margin-right':'30px'
                    });
                    plugin.el.after(plugin.nav);
     
                    $('.easyPaginateNav a.page, .easyPaginateNav a.first, .easyPaginateNav a.last, .easyPaginateNav a.debut', plugin).live('click', function () {
                        // e.defaultprevented;
                        displayPage($(this).attr('rel'));
                        $(this).addClass("current");
                    });
                    //clique sur précedent
                    $('.easyPaginateNav a.prev').live('click', function () {
                        page = plugin.settings.currentPage > 1 ? (plugin.settings.currentPage - 1) : 1;
                        displayPage(page);
     
     
                        return false;
                    });
                    // clique sur Suivant
                    $('.easyPaginateNav a.next').live('click', function () {
     
                        page = plugin.settings.currentPage < plugin.settings.pages ? (plugin.settings.currentPage + 1) : plugin.settings.pages;
                        displayPage(page);
     
                        return false;
                    });
                };
     
                displayPage = function (page, forceEffect) {
                    if (plugin.settings.currentPage != page) {
                        plugin.settings.currentPage = parseInt(page);
                        offsetStart = (page - 1) * (plugin.settings.elementsPerPage);
                        offsetEnd = page * plugin.settings.elementsPerPage;
                        if (typeof (forceEffect) != 'undefined') {
                            eval("transition_" + forceEffect + "(" + offsetStart + ", " + offsetEnd + ")");
                        } else {
                            eval("transition_" + plugin.settings.effect + "(" + offsetStart + ", " + offsetEnd + ")");
                        }
     
                        plugin.nav.find('.current').removeClass('current');
                        //important ==> plugin.nav.find('a.debut:eq(' + (page - 1) + ')').addClass('current');
                        if (plugin.settings.pages > 15) {
                            $('a.page', plugin).eq(page - 1).addClass('current');
     
     
                            for (i = 1; i <= plugin.settings.pages; i++) {
                                if ((parseInt($('a.page:eq(' + ((i + 2) - 1) + ')').attr('rel')) > (page + 2))
                                && (parseInt($('a.page:eq(' + ((i + 2) - 1) + ')').attr('rel')) <= (plugin.settings.pages - 3))
                                || (parseInt($('a.page:eq(' + ((i - 2) - 1) + ')').attr('rel')) < (page - 2)) && page >= 1) {
                                    if (parseInt($('a.page:eq(' + ((i + 2) - 1) + ')').attr('rel')) > (page + 2)
                                    && (parseInt($('a.page:eq(' + ((i + 2) - 1) + ')').attr('rel')) <= (plugin.settings.pages - 3))) {
                                        $('a.page:eq(' + ((i + 2) - 1) + ')').hide();
                                    }
                                    if (parseInt($('a.page:eq(' + ((i - 2) - 1) + ')').attr('rel')) < (page - 2) && page >= 1) {
                                        $('a.page:eq(' + ((i - 2) - 1) + ')').hide();
                                    }
     
                                }
     
     
                            }
                            $('a.page:eq(' + (page - 1) + ')').show();
                            Suite(plugin.settings.pages);
     
                        }
                        else {
                            $('a.page', plugin).eq(page - 1).addClass('current');
                        } //fin d'IF pages>15
                        switch (plugin.settings.currentPage) {
                            case 1:
                                $('.easyPaginateNav a', plugin).removeClass('disabled');
                                $('.easyPaginateNav a.first, .easyPaginateNav a.prev', plugin).addClass('disabled');
                                break;
                            case plugin.settings.pages:
                                $('.easyPaginateNav a', plugin).removeClass('disabled');
                                $('.easyPaginateNav a.last, .easyPaginateNav a.next', plugin).addClass('disabled');
                                break;
                            default:
                                $('.easyPaginateNav a', plugin).removeClass('disabled');
                                break;
                        }
                    }
                };
     
                transition_default = function (offsetStart, offsetEnd) {
                    plugin.currentElements.hide();
                    plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone();
                    plugin.el.html(plugin.currentElements);
                    plugin.currentElements.show();
                };
     
                transition_fade = function (offsetStart, offsetEnd) {
                    plugin.currentElements.fadeOut();
                    plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone();
                    plugin.el.html(plugin.currentElements);
                    plugin.currentElements.fadeIn();
                };
     
                transition_slide = function (offsetStart, offsetEnd) {
                    plugin.currentElements.animate({
                        'margin-left': plugin.settings.slideOffset * -1,
                        'opacity': 0
                    }, function () {
                        $(this).remove();
                    });
     
                    plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone();
                    plugin.currentElements.css({
                        'margin-left': plugin.settings.slideOffset,
                        'display': 'auto',
                        'opacity': 0,
                        'min-width': plugin.el.width() / 2
                    });
                    plugin.el.html(plugin.currentElements);
                    plugin.currentElements.animate({
                        'margin-left': 0,
                        'opacity': 1
                    });
                };
     
                transition_climb = function (offsetStart, offsetEnd) {
                    plugin.currentElements.each(function (i) {
                        $objThis = $(this);
                        setTimeout(function () {
                            $objThis.animate({
                                'margin-left': plugin.settings.slideOffset * -1,
                                //'max-width': 30,
                                'opacity': 0
                            }, function () {
                                $(this).remove();
                            });
                        }, i * 200);
                    });
     
                    plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone();
                    plugin.currentElements.css({
                        'margin-left': plugin.settings.slideOffset * -1,
                        //'margin-left': 'auto',
                        'display': 'auto',
                        //'position': 'relative',
                        'opacity': 0
                        //'width': 20+'em',
                        //'max-width':40+'em',
                        //'min-width': plugin.el.width() / 2
                    });
                    //èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
     
                    //'''''''''''''''''''''''''''''
                    plugin.el.html(plugin.currentElements);
                    plugin.currentElements.each(function (i) {
                       var $objThis = $(this);
                        setTimeout(function () {
                            $objThis.animate({
                                'margin-left': 0,
                                'display': 'auto',
                                'opacity': 1
                            });
                        }, i * 200);
                    });
                };
     
                plugin.settings = $.extend({}, defaults, options);
     
                plugin.currentElements = $([]);
                plugin.settings.objElements = plugin.el.find(plugin.settings.paginateElement);
                plugin.settings.pages = getNbOfPages();
                if (plugin.settings.pages > 1) {
                    plugin.el.html();
     
                    // Here we go
                    displayNav();
     
                    page = 1;
                    if (document.location.hash.indexOf('#' + plugin.settings.hashPage + ':') != -1) {
                        page = parseInt(document.location.hash.replace('#' + plugin.settings.hashPage + ':', ''));
                        if (page.length <= 0 || page < 1 || page > plugin.settings.pages) {
                            page = 1;
                            plugin.settings.currentPage = 1;
                        }
                    }
     
                    displayPage(page, 'default');
                }
            });
        };
    })(jQuery);
    Images attachées Images attachées  

  2. #2
    Expert confirmé Avatar de Toufik83
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    2 405
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2012
    Messages : 2 405
    Points : 4 841
    Points
    4 841
    Par défaut
    je vous donne le code Ajax qui permet de charger les données et les paginer au démarrage de l'application :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    function Charger_Intial() {
            //var str = $("#txtrech").val();
            $.ajax({
                type: "POST",
                url: "Default.aspx/Charger_donnee",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                cache: false,
                success: function (msg) {
                    if (msg.d.length > 0) {
                        for (var i = 0; i < msg.d.length; i++) {
                           // $("#TblInit").append("<tr  class='ligne' id='" + msg.d[i].Id_cat + "'> <td></td> <td><a data-reveal-id='myModal' data-animation='fade' class='big-link'>Editer</a></td> <td> " + msg.d[i].Id_cat + "</td> <td>" + msg.d[i].Titre + "</td> <td> " + msg.d[i].Image + " </td> <td> " + msg.d[i].Date + " </td>" +
                            //"<td>" + msg.d[i].Id_admin + "</td><td>" + msg.d[i].devis + "</td><td>" + msg.d[i].active_cat + "</td><td>" + msg.d[i].envoivMar + "</td><td>" + msg.d[i].group_repr + "</td><td>" + msg.d[i].id_adminp + "</td><td>" + msg.d[i].order_cat + "</td></tr>  ");
                            $("#divContenent").append("<span id='" + msg.d[i].Id_cat + "'>" +
                            "<a>Supprimer</a><a id='" + msg.d[i].Id_cat + "'  data-reveal-id='myModal' data-animation='fade' class='Editer'>Editer</a>" +
                            "<a style='width:1.2em'> " + msg.d[i].Id_cat + "</a> <a style='width:8em'>" + msg.d[i].Titre + "</a>" +
                            "<a style='width:7em'>" + msg.d[i].Image + "</a> <a style='width:7em'>" + msg.d[i].Date +"</a>"+
                             "<a style='width:3.6em'>" + msg.d[i].Id_admin + "</a>" +
                             "<a style='width:2.7em;'>" + msg.d[i].devis + "</a>" +
                             "<a style='width:7em'>" + msg.d[i].active_cat + "</a>" +
                             "<a style='width:5em;'>" + msg.d[i].envoivMar + "</a>" +
                             "<a style='width:5em;'>" + msg.d[i].group_repr + "</a>" +
                             "<a style='width:4em;'>" + msg.d[i].id_adminp + "</a>" +
                             "<a style='width:7em'>" + msg.d[i].order_cat + "</a></span>");
                            
                        }
    
                    }
                    else {
                        $("#divContenent span").remove();
                        $("#divContenent").append("<span><a>pas de résultat</a></span>");
                    }
                },
                complete: function (msg) {
                    /*if ($(".tableUtils_paginationDiv").length > 0) {
                    $(".tableUtils_paginationDiv").append("HOOOOOOOO");
                    }*/
                    if ($(".easyPaginateNav").length > 0) { //alert("OUI");
                        $(".easyPaginateNav").remove();
                    }
                    $('#divContenent').easyPaginate({
                        elementsPerPage: "10",
                        effect: "climb"
                    });
                }
    
            });
            //return false;
        }
    puis j'utilise une fonction qui permet de faire le Trie des données (ASC DESC) :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    $("a.Trie").live("click", function () {
                var href = $(this).attr("id").toString();
                //alert("OUIIIIII");
                var ordre = "";
                if ($("#etat").val() != "") {
                    ordre = $("#etat").val();
                }
                var envoieTrie = { donnee: href, ord: ordre }
                //alert(href);
                $.ajax({
                    type: "POST",
                    url: "Default.aspx/Trie",
                    data: JSON.stringify(envoieTrie),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    cache:false,
                    success: function (Tmsg) {
                        $("#divContenent span").remove();
    
                        for (var i = 0; i < Tmsg.d.length; i++) {
                            $("#divContenent").append("<span id='" + Tmsg.d[i].Id_cat + "' > <a>Supprimer</a>" +
                            "<a id='" + Tmsg.d[i].Id_cat + "' class='Editer' data-reveal-id='myModal' data-animation='fade' >Editer</a>" +
                            "<a id='A_Id_cat' style='width:1.2em'>" + Tmsg.d[i].Id_cat + "</a>" +
                            "<a id='A_Titre_cat' style='width:8em'>" + Tmsg.d[i].Titre + "</a>" +
                            "<a id='A_image_cat' style='width:7em'>" + Tmsg.d[i].Image + "</a>" +
                            "<a id='A_date_modif' style='width:7em'>" + Tmsg.d[i].Date + "</a>" +
                             "<a id='A_id_admin' style='width:3.6em'>" + Tmsg.d[i].Id_admin + "</a>" +
                             "<a id='A_devis' style='width:2.7em;'>" + Tmsg.d[i].devis + "</a>" +
                             "<a id='A_active_cat' style='width:7em'>" + Tmsg.d[i].active_cat + "</a>" +
                             "<a id='A_envoivMar' style='width:5em;'>" + Tmsg.d[i].envoivMar + "</a>" +
                             "<a id='A_group_repr' style='width:5em;'>" + Tmsg.d[i].group_repr + "</a>" +
                             "<a id='A_id_adminp' style='width:4em;'>" + Tmsg.d[i].id_adminp + "</a>" +
                             "<a id='A_order_cat' style='width:7em'>" + Tmsg.d[i].order_cat + "</a></span>");
                        }
    
                    },
                    complete: function (Tmsg) {
                        //alert($("#etat").val());
                        $("a#" + href + ".Trie br").remove("");
                        $("#divContenent span a#A_" + href).addClass("colonne");
                        if ($("#etat").val().toString() == "ASC") {
                            $("#etat").val("DESC");
                            if ($("#sort").length > 0) {
                                $("#sort").remove();
    
                            }
                            $("a#" + href + ".Trie").append("<img id='sort' class='monimage' style='width:1.8em;height:.8em'  alt='TrieImg' src='image/TRIEHAUT.png'/>");
                        }
                        else if ($("#etat").val().toString() == "DESC") {
                            $("#etat").val("ASC");
                            if ($("#sort").length > 0) {
                                $("#sort").remove();
    
                            }
                            $("a#" + href + ".Trie").append("<img id='sort' class='monimage' style='width:1.8em;height:.8em' alt='TrieImg' src='image/TRIEBAS.png'/>");
                        }
                        if ($(".easyPaginateNav").length > 0) { //alert("OUI");
                            $(".easyPaginateNav").remove();
                        }
                        $('#divContenent').easyPaginate({
                            elementsPerPage: "10",
                            effect: "climb"
                        });
                    }
                });
                return false;
            });
    ensuite la fonction qui permet la recherche selon le KeyUp de la zone de texte :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    $("#txtrech").live("keyup", function () {
    
                if ($("#txtrech").val() != "") {
                    var envoie = { data: $("#txtrech").val(), prenom: "toufik" }
                    var nbrligne = 0;
                    $.ajax({
                        type: "POST",
                        url: "Default.aspx/Afficher",
                        data: JSON.stringify(envoie),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            if (msg.d.length > 0) {
                                nbrligne = msg.d.length;
                                //alert(nbrligne);
                                $("#divContenent span").remove();
    
                                for (var i = 0; i < msg.d.length; i++) {
                                    $("#divContenent").append("<span id='" + msg.d[i].Id_cat + "' >" +
                                    "<a >Supprimer</a><a class='big-link' data-reveal-id='myModal' data-animation='fade' >Editer</a>" +
                                    "<a style='width:1.2em'> " + msg.d[i].Id_cat + "</a> <a style='width:8em'>" + msg.d[i].Titre + "</a>" +
                                    "<a style='width:7em'> " + msg.d[i].Image + " </a> <a style='width:7em'> " + msg.d[i].Date + "</a>" +
                                    "<a style='width:3.6em'>" + msg.d[i].Id_admin + "</a><a style='width:2.7em;'>" + msg.d[i].devis + "</a>" +
                                    "<a style='width:7em'>" + msg.d[i].active_cat + "</a><a style='width:5em'>" + msg.d[i].envoivMar + "</a>" +
                                    "<a style='width:5em'>" + msg.d[i].group_repr + "</a><a style='width:4em'>" + msg.d[i].id_adminp + "</a>" +
                                    "<a style='width:7em'>" + msg.d[i].order_cat + "</a></span>");
                                }
    
                            }
                            else {
                                $("#divContenent span").remove();
                                
                                $("#divContenent").append("<span id='aucun'><a>pas de résultat</a></span>");
                            }
                            if ($("#sort").length > 0) {
                                    $("#sort").remove();
    
                                }
    
                        },
                        complete: function (msg) {
                            if ($(".easyPaginateNav").length > 0) { //alert("OUI");
                                $(".easyPaginateNav").remove();
                            }
                            $('#divContenent').easyPaginate({
                                elementsPerPage: "10",
                                effect: "climb"
                            });
                        }
    
                    });
                    //return false;
                }
                else {
    
                    $("#divContenent span").remove();
                    $("#divContenent").append("<span id='aucun'><a>pas de résultat</a></span>");
                    Charger_Intial();
                    if ($("#aucun").length > 0) {
                        //alert("oui");
                        $("#aucun").remove();
                    }
    
                }
            });
    comme vous voyez j'utilise la fonction $('#divContenent').easyPaginate({}) plusieurs fois et a chaque fois que je l'utilise (Trie ou Recherche ou chargement Initial...) et que je clique sur page suivante, le plugin saute les pages. je vous donne un exemple :

    la page est chargé puis je clique sur Trie des colonnes, quand je clique sur page suivante, il passe directement de la page 1 a la page 3.(saute de page 2) et si par exemple je fais une recherche depuis la zone de texte, et que je fais page suivante, ben il passe directement de la page 1 a la page 4.(saute des pages 2 et 3)...., est ce qu'il y'a quelqu'un qui peut m'aider s'il vous plait?

  3. #3
    Rédacteur

    Avatar de danielhagnoul
    Homme Profil pro
    Étudiant perpétuel
    Inscrit en
    Février 2009
    Messages
    6 389
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 73
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant perpétuel
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2009
    Messages : 6 389
    Points : 22 933
    Points
    22 933
    Billets dans le blog
    125
    Par défaut
    Je ne vois pas pourquoi vous répéter trois fois l'initialisation du plugin :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    $('#divContenent').easyPaginate({
        elementsPerPage: "10",
        effect: "climb"
    });
    Dans votre code, vous ne dites pas quel élément doit-être paginé, exemple :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    $('#easyPaginate').easyPaginate({
        paginateElement: 'img',
        elementsPerPage: 3,
        effect: 'climb'
    });

    Blog

    Sans l'analyse et la conception, la programmation est l'art d'ajouter des bogues à un fichier texte vide.
    (Louis Srygley : Without requirements or design, programming is the art of adding bugs to an empty text file.)

  4. #4
    Expert confirmé Avatar de Toufik83
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    2 405
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2012
    Messages : 2 405
    Points : 4 841
    Points
    4 841
    Par défaut
    j'utilise le plugin comme un fichier javascript que j'importe dans le début de ma page Aspx :
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <script type="text/javascript" src="Scripts/jquery.easyPaginate.js"></script>

    j'ai besoin de paginer les résultats a chaque fois que l'utilisateur fait (chargement initiale de la page, Le Trie, La recherche via la zone de texte)
    en ce qui concerne PaginateElement, il est déclaré dans le plugin au début :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    defaults = {
                paginateElement: 'span',
                hashPage: 'page',
                elementsPerPage: 3,
                effect: 'default',
                slideOffset: 200,
                firstButton: true,
                firstButtonText: '<<',
                lastButton: true,
                lastButtonText: '>>',
                prevButton: true,
                prevButtonText: '<',
                nextButton: true,
                nextButtonText: '>',
                onSomeEvent: function () { }
            }
    comment faire pour ne pas initialiser le plugin qu'une fois, puis l'utiliser plusieurs fois ?

  5. #5
    Expert confirmé Avatar de Toufik83
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    2 405
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2012
    Messages : 2 405
    Points : 4 841
    Points
    4 841
    Par défaut
    Comment je dois faire pour ne pas initialiser le plugin a chaque fois que je veux l'utiliser?

  6. #6
    Expert confirmé Avatar de Toufik83
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    2 405
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2012
    Messages : 2 405
    Points : 4 841
    Points
    4 841
    Par défaut
    salut danielhagnoul,
    j'ai fais quelques recherches mais je suis toujours bloquer, je crois que le problème réside ici :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    //clique précédant
    $('.easyPaginateNav a.prev').live('click', function () {
        page = plugin.settings.currentPage > 1 ? (plugin.settings.currentPage - 1) : 1;
        displayPage(page);
        return false;
    });
    // clique sur Suivant
    $('.easyPaginateNav a.next').live('click', function () {
        page = plugin.settings.currentPage < plugin.settings.pages ? (plugin.settings.currentPage + 1) : plugin.settings.pages;
        displayPage(page);
        return false;
    });
    la variable page est incrémenté a chaque utilisation du script easyPaginate.js,

  7. #7
    Rédacteur

    Avatar de danielhagnoul
    Homme Profil pro
    Étudiant perpétuel
    Inscrit en
    Février 2009
    Messages
    6 389
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 73
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant perpétuel
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2009
    Messages : 6 389
    Points : 22 933
    Points
    22 933
    Billets dans le blog
    125
    Par défaut
    Je viens de tester le plugin avec l'exemple de base.

    Lors de son initialisation, le plugin apporte plusieurs modifications aux codes HTML et CSS. Il n'est pas conçu pour prendre en compte l'ajout ou la suppression d'éléments après son initialisation.

    Il faut choisir un plugin qui accepte des modifications dynamiques.

    Je manque de temps libre pour trouver et tester le bon plugin.

    Liste de plugins : http://jqueryhouse.com/jquery-pagination-plugins/

    Dynamique oui ? : http://botmonster.com/jquery-bootpag/#.VE9MUTSUdJk

    Dynamique non ? mais une méthode destroy : http://luis-almeida.github.io/jPages/destroy.html

    Dynamique oui, datatable avec pagination : http://holt59.github.io/datatable/

    Blog

    Sans l'analyse et la conception, la programmation est l'art d'ajouter des bogues à un fichier texte vide.
    (Louis Srygley : Without requirements or design, programming is the art of adding bugs to an empty text file.)

  8. #8
    Expert confirmé Avatar de Toufik83
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    2 405
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2012
    Messages : 2 405
    Points : 4 841
    Points
    4 841
    Par défaut
    Salut danielhagnoul,

    Merci pour tes éclaircissements remarquables, c'est vrai que le plugin ne gère pas la suppression des éléments ainsi que la barre de navigation des pages 1234...., par ce que a chaque fois que je l'utilise je vérifie l'existence de la barre, si elle existe je la supprime afin que le plugin génère la nouvelle barre de navigation.

    le problème vient de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     (plugin.settings.currentPage+1) et (plugin.settings.currentPage-1)
    le faite d'utiliser le plugin 2 fois par exemple, le settings.currentPage il se double (vu qu'on a utiliser le plugin 2 fois), dans ce cas y'aura qu'une seule page qui va sauter, et si je

    l'utilise encore une fois, ben plugin.settings.currentPage il se triple, c'est a dire que cette fois il va sauter 2 pages... et ainsi de suite.

Discussions similaires

  1. Réponses: 5
    Dernier message: 01/03/2015, 19h02
  2. [2.x] Utiliser le même formulaire plusieurs fois dans la même page
    Par Daecarios dans le forum Symfony
    Réponses: 3
    Dernier message: 06/07/2012, 14h53
  3. utilisation de script js plusieurs fois dans une même page
    Par tribalnanasss dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 09/07/2010, 00h34
  4. Réponses: 2
    Dernier message: 18/07/2007, 08h38
  5. [C#][SVG] Combinaison de plusieurs graphe sur une même page
    Par doudoustephane dans le forum ASP.NET
    Réponses: 2
    Dernier message: 22/11/2006, 09h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo