开发者

jQuery Slider using .load - Possible use for delegate()

开发者 https://www.devze.com 2023-03-08 08:01 出处:网络
I have开发者_StackOverflow a website that loads each page using jQuerys .load function which is all working fine.

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消