Created
May 20, 2011 14:58
-
-
Save clawfire/983084 to your computer and use it in GitHub Desktop.
Load dynamic content for a caroussel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $("#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}); | |
| }); | |
| } | |
| }) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Il est possible d'eviter la duplication du code mais cela necessite de faire un test sur les deux précédentes conditions :(