I have created a slideshow to go on a zencart site. The slidehow page is an external file that is loaded via AJAX. Please find the code snippet below.
jQuery(document).ready(function() {
//Load the slideshow page
jQuery("#slidershow").load("/xxxxxxxxxx/index.php?main_page=page&id=2 #slider");
//Targetting live content, #slider is loaded via AJAX
jQuery("#slider").live("click" ,function(){jQuery(this).s3Slide开发者_如何学JAVAr({timeOut:5000});});
});
Instead of live("click"...) I would like it to appear onload automatically.. But live() does not support "load". What other ways I could get the plugin to trigger onload? hope the question is clear.
Make use of the callback function:
jQuery(document).ready(function() {
//Load the slideshow page
jQuery("#slidershow").load("/the-url.php #slider", function () {
// as soon as the ajax content is loaded, start the slideshow:
jQuery(this).s3Slider({timeOut:5000});
});
});
精彩评论