最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Holding document.Ready() sometime with jquery holdReady function - Stack Overflow

programmeradmin2浏览0评论

Here I am facing an issue with jquery holdReady .

 $.holdReady(true);
    $.getScript("someXJqueryPlugin.js", function() {
    $.holdReady(false);
    });

In my ready function

$(document).ready(function(){
 someFunctionFromMyPlugin();
});

Because of someXJqueryPlugin.js is some what bigger in size .So i am trying to delay the the ready function untill my plugin loaded.

Still iam getting the error someFunctionFromMyPlugin not a function .

Any hints ??What I am missing ?? please help .

Thanks in advance.

Here I am facing an issue with jquery holdReady .

 $.holdReady(true);
    $.getScript("someXJqueryPlugin.js", function() {
    $.holdReady(false);
    });

In my ready function

$(document).ready(function(){
 someFunctionFromMyPlugin();
});

Because of someXJqueryPlugin.js is some what bigger in size .So i am trying to delay the the ready function untill my plugin loaded.

Still iam getting the error someFunctionFromMyPlugin not a function .

Any hints ??What I am missing ?? please help .

Thanks in advance.

Share Improve this question edited Feb 21, 2013 at 19:15 Suresh Atta asked Feb 21, 2013 at 19:08 Suresh AttaSuresh Atta 122k38 gold badges206 silver badges315 bronze badges 3
  • I cross checked with my path of js .its correct . – Suresh Atta Commented Feb 21, 2013 at 19:10
  • 2 This depends heavily on your code. Most likely the ready event has already fired. You need to call holdready asap, the best would be directly in the head. – Christoph Commented Feb 21, 2013 at 19:16
  • @Christoph ok.Let me give a try . – Suresh Atta Commented Feb 21, 2013 at 19:19
Add a ment  | 

1 Answer 1

Reset to default 5

I'd suggest placing the document ready inside of the done callback.

$.getScript(url,function(){
    $(document).ready(function(){
        // do stuff
    });
});

or using deferreds:

$.when( $.getScript(url), $.ready ).done(function(){
    // do stuff
});

Note $.ready is not documented and is subject to change, you can replace it with the following for a more stable version:

$.when( $.getScript(url), $.Deferred(function(def){
    $(def.resolve);
})).done(function(){
    // do stuff
});
发布评论

评论列表(0)

  1. 暂无评论