开发者

jQuery code will not run unless stepped through with Firebug

I have a problem with some jQuery code. For some reason it will not run automatically when its supposed to however when stepping through with Firebug it works fine?

I put a breakpoint on the code that's not firing automatically and then press play on Firebug and it works fine if I take away this breakpoint or close down Firebug it does not run? Can somebody please help, I've searched the internet but not found anything relevant.

The code should run when I click a link which will cr开发者_JAVA技巧eate a jQuery tab on my main page and open an external page onto this tab - The external page also includes jQuery to run a lightbox so had to put an id on the link that I click to activate the lightbox code (this is the code that wont fire without the breakpoint).

Link:

 <a onclick="createNewTab('dhtmlgoodies_tabView1','Remote Access','','RemoteAccess.html',true);return false" id="lightbox_load">Remote Access</a>

Code not running:

$(function(){                   
    // Lighbox Link
    $('#lightbox_load').click(function(){
    $('#RemoteAccessGallery a').lightBox({fixedNavigation:true});        }); });


I think there is a race condition with your onclick and the jquery .live addition. What happens if you bring the createNewTab('dhtmlgoodies_tabView1','Remote Access','',... inside click anonymous function?


try :

$(function(){                   
    // Lighbox Link
    $('#lightbox_load').live("click", function(){
        $('#RemoteAccessGallery a').lightBox({fixedNavigation:true});
    });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜