Help with an image slider & load();
Hi I'm new to jquery and am trying to figure out a problem. I've spent the last couple of days scratching my head over it, and figured maybe an expert can help me.
My Goal: to load pages of content into the main page when a link is clicked, THEN create an image slider based on the content that was loaded.
So far I've got this tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/
It uses the load(); function. It seems to work fine for loading other html pages. Great!
And I've used easySlider 1.7 plug-in (http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider)
It creates a slider from an unordered list of images. And it works on a page by itself.
The 'gotcha' is I can't get the easySlider to run after the load(); does it's thing.
- $(document).ready(function() {
-
- // Check for hash value in URL
- var hash = window.location.hash.substr(1);
- var href = $('#nav li a').each(function(){
- var href = $(this).attr('href');
- if(hash==href.substr(0,href.length-5)){
- var toLoad = hash+'.html #content';
- $('#content').load(toLoad)
- }
- });
-
- // when a link is clicked
- $('#nav li a').click(function(){
- var toLoad = $(this).attr('href')+' #content';
- $('#content').hide('fast',loadContent);
- $('#load').remove();
- $('#wrapper').append('<span id="load">LOADING...</span>');
- $('#load').fadeIn('normal');
- window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
-
- function loadContent() {
- $('#content').load(toLoad,'',showNewContent())
- }
- function showNewContent() {
- $('#content').show('normal',hideLoader());
- }
- function hideLoader() {
- $('#load').fadeOut('normal',slideme());
- }
-
- // This easySlider works on it's own,
- // but not when it's called in here after content is loaded
- $("#portfolio-slider").easySlider({
- auto: true, continuous: true, numeric: true,
- speed: 900, pause: 2200
- });
-
-
- return false;
- });
Can someone please advise me on how to call the easySlider after the content is finished loading.
Thanks!