开发者

How to Call document.ready(function()) routines during a .load() Call

I have the following line in my document.ready() section, i.e.

$(document).ready(function()
{
    // initialize scrollable
    $("#browsable").scrollable();
});

This all works fine at initial page start-up, which is my "Home" menu option. The problem is, I have a side menu where the user clicks on an option, which then loads my html page in using jQuery .load(), based on the option selected, such as "About Us".

But when the user clicks back on the "Home" menu option, after just leaving the "About Us" page, my $("#browsable").scrollable(); is not being initialized/called again, which causes issues with my carousel.

Using this .load() call, how can I get it to redo initialization using开发者_StackOverflow $("#browsable").scrollable(); call?

Thanks.


According to the jQuery Documentation, you can set a call back in the load call, like this...

$('#result').load('ajax/test.html', function() {
    $("#browsable").scrollable();
});

Source: http://api.jquery.com/load/


Take a look at the live method. Or use the callback function of the load function to initialize the scrollable plug-in on the loaded content, as Sohnee suggests.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜