开发者

Beginner question of yepnope & jquery & modernizr

I'm absolute beginner for yepnope and modernizr. I'm trying to test some example. So my question is: when jquery loads from a 3rd party CDN. It's working fine. But when jquery loads from a local, domready function don't work? Why? Am I coding wrong style?

yepnope([{
    load: 'http://code.jquery.com/jquery-1.5.9.js'
    , callback: function(result, key) {
      if(!window.jQuery) {
        yepnope('/javascripts/jquery.min.js');
        alert("Loaded jQuery from a local!");
      } else {
     开发者_开发技巧   alert("Loaded jQuery from a 3rd party CDN!");
      }
    }, complete: function() {
      $(function(){
        alert("DOM ready!");
      });
    }
  }]);


Your code should work, and is tested in the yepnope test suite.

You may be running into a timeout issue, though. In most browsers, error reporting/handling isn't possible on asynchronous script loading in a consistent or reliable way, so yepnope implements a script timeout in the cases when scripts never call back. So if the version of jQuery you are loading first doesn't exist, it may take 10 seconds (by default, but changeable via yepnope.errorTimeout ) for the callback and complete handler to run. It is an unfortunate downside of trying to load things this way.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜