jQuery Slider using .load - Possible use for delegate()
I have开发者_StackOverflow a website that loads each page using jQuerys .load function which is all working fine.
The issue I have is that a slider on one of the pages doesnt work when loaded in, whereas if written on the main document itself it works correctly. As I understand when using .load certain aspects don't work correctly and the need for delegate()
comes in.
What I can't work out is how to turn this jQuery into something that will work on each page:
// jQuery Slider Script
$("#navi ul").tabs("#panes > div", {
effect: 'fade',
fadeOutSpeed: 500,
rotate: true
}).slideshow({
autoplay: true,
interval: 6000
});
I have tried using both delegate()
and live()
but haven't managed to get it working.
Any help would be great!
Thanks :)
put the javascript inside a
<script type="text/javascript">
$(document).ready(
)
</script>
Without seeing the rest of your code, it seems like the problem is that you need to do this:
$("#navi ul").tabs("#panes > div", {
effect: 'fade',
fadeOutSpeed: 500,
rotate: true
}).slideshow({
autoplay: true,
interval: 6000
});
Within the callback function of your .load event. http://api.jquery.com/load/
$('#result').load('ajax/test.html', function() {
alert('Callback code here.');
});
After hours of messing, I finally solved it.
Adding the jQuery code to slider file that was being loaded solved the issue.
Sorry for a noob question!
精彩评论