[ 3 posts ]

lupin

  • Joined: Mon Jun 25, 2012 9:59 pm
  • Posts: 2
  • Offline
  • Profile

How to use yui loader 3rd party lib like jquery?

Post Posted: Mon Jun 25, 2012 10:01 pm
+0-
Here is my test code:
Code:
<script type="text/javascript">
   YUI({
      modules: {
         'jquery': {
            fullpath: 'script/lib/jquery.min.js'
         },
         'jquery-blockui': {
            fullpath: 'script/lib/jquery.blockUI.js',
            requires: ['jquery']
         }
      }
   }).use('jquery-blockui', function(Y, result){
      $.blockUI();
   });
</script>

When it run, sometimes it work, sometimes dont work. Because jquery lib loaded after jquery-blockui.
errors like:
Code:
Uncaught ReferenceError: jQuery is not defined
Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'blockUI'

So, What's wrong with the code?

Alberto Santini

YUI Contributor

  • Offline
  • Profile

Re: How to use yui loader 3rd party lib like jquery?

Post Posted: Mon Jun 25, 2012 11:34 pm
+0-
Hello lupin.

Maybe it is due to async loading:
http://yuilibrary.com/yui/docs/yui/#async

Hope that helps,
IceBox

P.S.: If your custom modules are properly wrapped in a YUI.add callback, you will see no difference at all (async false or true), but this is not the case with external libraries.

lupin

  • Joined: Mon Jun 25, 2012 9:59 pm
  • Posts: 2
  • Offline
  • Profile
Tags:

Re: How to use yui loader 3rd party lib like jquery?

Post Posted: Mon Jun 25, 2012 11:58 pm
+0-
It work perfect.

Thank a lot.
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum