Voila comme je gere la pagination.
Je met un form avec toutes les options visibles ou pas.
Quand je clique sur 2 ca met a jour un input hidden avec le numero de la page 2 et je valider le formulaire en AJAX ...
Donc je serais toi vu que c'est un array tu peux le serializer dans un input hidden et le recuperer apres ...
<form>
<input type="hidden" name="villes" value="<?php echo serialize($_GET['ville']); ?>" />
<input type="hidden" name="page" value="<?php echo $_GET['page']; ?>" />
</form>
Apres je recupere les variables avec $_REQUEST pour que ca arrive en $_GET ou en $_POST.
Tu peux voir un exemple ici :
http://www.subsynchro.com/tous-les-film ... /asc/nb/2/
Le javascript est un peu complexe mais compréhensible :
[javascript] // On met à jour les listes d'informations
function updateList() {
$.ajax({
type: 'POST',
url: 'include/ajax/'+$('#action').val()+'.php',
data:$('#afficher').serialize(),
processData: true,
async: false,
error:function(msg){
alert( 'Error !: include/ajax/'+$('#action').val()+'.php?'+$('#afficher').serialize() );
},
beforeSend:function() {
$('#result').html('<div id="chargement">Merci de patienter. Chargement des informations en cours.</div>');
},
success:function(data){
$('#result').html(data);
navigation();
$("a.colorbox").colorbox({ maxWidth:'90%', maxHeight:'90%', scalePhotos: true });
$('.tipped_ajax').each(function() { Tipped.create(this, { ajax: { data: $(this).data('querystring') }, skin: 'white', hook: 'topright' }); });
$('.tooltip').tooltipster({ theme: '.tooltipster-light' });
// On cache les notes vides
$('#affichage_vignette').is(':checked') ? $('.col5:contains("-")').hide() : $('.col5:contains("-")').show();
}
});
}
// Les boutons permettant la navigation
function navigation() {
$('.navigation-precedent a, .navigation-suivant a, .navigation li a').on('click', function() {
var num = $(this).attr('rel');
$.scrollTo($('#principale'), 1000, function() {
var nb = $('#nb').val();
var length = $('.navigation li').length;
var last = 0;
$('.navigation li').each(function(i, li) {
if(i == length-2) last = $(this).children().html();
});
if(num == 'precedent') {
// Si ce n'est pas la première page
if(nb > 1) {
var target = parseInt(nb)-1;
$('#nb').val(target);
updateList();
}
} else if(num == 'suivant') {
// Si ce n'est pas la première page
if(nb < last) {
var target = parseInt(nb)+1;
$('#nb').val(target);
updateList();
}
} else {
$('#nb').val(num.substr(5));
updateList();
}
});
return false;
});
}[/javascript]
Voila comme je gere la pagination.
Je met un form avec toutes les options visibles ou pas.
Quand je clique sur 2 ca met a jour un input hidden avec le numero de la page 2 et je valider le formulaire en AJAX ...
Donc je serais toi vu que c'est un array tu peux le serializer dans un input hidden et le recuperer apres ...
[html]<form>
<input type="hidden" name="villes" value="<?php echo serialize($_GET['ville']); ?>" />
<input type="hidden" name="page" value="<?php echo $_GET['page']; ?>" />
</form>[/html]
Apres je recupere les variables avec $_REQUEST pour que ca arrive en $_GET ou en $_POST.
Tu peux voir un exemple ici : http://www.subsynchro.com/tous-les-films/search/where/titre/order/asc/nb/2/
Le javascript est un peu complexe mais compréhensible :
[javascript] // On met à jour les listes d'informations
function updateList() {
$.ajax({
type: 'POST',
url: 'include/ajax/'+$('#action').val()+'.php',
data:$('#afficher').serialize(),
processData: true,
async: false,
error:function(msg){
alert( 'Error !: include/ajax/'+$('#action').val()+'.php?'+$('#afficher').serialize() );
},
beforeSend:function() {
$('#result').html('<div id="chargement">Merci de patienter. Chargement des informations en cours.</div>');
},
success:function(data){
$('#result').html(data);
navigation();
$("a.colorbox").colorbox({ maxWidth:'90%', maxHeight:'90%', scalePhotos: true });
$('.tipped_ajax').each(function() { Tipped.create(this, { ajax: { data: $(this).data('querystring') }, skin: 'white', hook: 'topright' }); });
$('.tooltip').tooltipster({ theme: '.tooltipster-light' });
// On cache les notes vides
$('#affichage_vignette').is(':checked') ? $('.col5:contains("-")').hide() : $('.col5:contains("-")').show();
}
});
}
// Les boutons permettant la navigation
function navigation() {
$('.navigation-precedent a, .navigation-suivant a, .navigation li a').on('click', function() {
var num = $(this).attr('rel');
$.scrollTo($('#principale'), 1000, function() {
var nb = $('#nb').val();
var length = $('.navigation li').length;
var last = 0;
$('.navigation li').each(function(i, li) {
if(i == length-2) last = $(this).children().html();
});
if(num == 'precedent') {
// Si ce n'est pas la première page
if(nb > 1) {
var target = parseInt(nb)-1;
$('#nb').val(target);
updateList();
}
} else if(num == 'suivant') {
// Si ce n'est pas la première page
if(nb < last) {
var target = parseInt(nb)+1;
$('#nb').val(target);
updateList();
}
} else {
$('#nb').val(num.substr(5));
updateList();
}
});
return false;
});
}[/javascript]