Skip to content

Instantly share code, notes, and snippets.

@clawfire
Created May 20, 2011 14:58
Show Gist options
  • Select an option

  • Save clawfire/983084 to your computer and use it in GitHub Desktop.

Select an option

Save clawfire/983084 to your computer and use it in GitHub Desktop.
Load dynamic content for a caroussel
$("#caroussel-arrow ul li button").click(function(){
var clicked_arrow = $(this).attr('id');
var current_categ = $("#caroussel-content").data('config').categ;
var current_offset = $("#caroussel-content").data('config').offset;
if(clicked_arrow == 'right' && current_offset<12){
$("#caroussel-content").html("<img class='loading' src='' alt='loading'/>")
var new_offset = current_offset+4;
console.log('droite and offset '+new_offset);
$.get(templatePath+'/inc/caroussel.php',{ loop: current_categ , offset: new_offset},function(data){
$("#caroussel-content").html(data);
$("#caroussel-content").data('config', {categ: current_categ, offset : new_offset});
});
}else if(clicked_arrow == 'left' && current_offset>0){
$("#caroussel-content").html("<img class='loading' src='' alt='loading'/>")
var new_offset = current_offset-4;
console.log('gauche and offset '+new_offset);
$.get(templatePath+'/inc/caroussel.php',{ loop: current_categ , offset: new_offset},function(data){
$("#caroussel-content").html(data);
$("#caroussel-content").data('config', {categ: current_categ, offset : new_offset});
});
}
})
@clawfire

Copy link
Copy Markdown
Author

Il est possible d'eviter la duplication du code mais cela necessite de faire un test sur les deux précédentes conditions :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment