I am getting the following error:
Uncaught ReferenceError : jQuery is not defined
for the following code
jQuery.extend(Drupal.settings, {"fb":{"ajax_event_url":"http:\/\/www.whackk.com\/fb\/ajax","fb_init_settings":{"xfbml":false,"status":false,"cookie":true,"channelUrl":"http:\/\/www.whackk.com\/fb\/channel"},"controls":"","js_sdk_url":"http:\/\/connect.facebook.net\/en_US\/all.js"}});
The above code is being inserted by the fbconnect (http://drupal.org/project/fbconnect) module.
I am also getting the same error for my hoverIntent jQuery plugin which I am loading separately using head.js(); along with other plugins like superfish and supersub. But this does not happen all the. Only on some instances, mostly when I load the page using ctrl+shift+r
None of the other jQuery plugins are showing any error.
Any idea what might be the possible reasons for the error. Rest of my javascript works fine. Even the stuff that depends on jQuery. It's probably a loading/executing sequence error where jQuery loads after these scripts. Am I right?
Since I am reporting one error, I might as well report another one related to the fbconnect module :
Uncaught TypeError: Cannot read property 'loginout_mode' of undefined
for the following code:
Drupal.fbconnect=Drupal.fbconnect||{};Drupal.fbconnect.init=function(){Drupal.behaviors.fbconnect=function(context){if(context!=document)jQuery(context).each(function(){FB.XFBML.parse(this)});Drupal.fbconnect.initLogoutLinks(context)};if(Drupal.settings.fbconnect.loginout_mode=='auto')FB.Event.subscribe('auth.sessionChange',Drupal.fbconnect.reload_ifUserConnected);Drupal.behaviors.fbconnect(document)};Drupal.fbconnect.logout=function(keep_fbaccount_logged){var logout_url=Drupal.settings.basePath+'logout';if(!keep_fbaccount_logged){FB.logout(function(response){window.location.href=logout_url})}else window.location.href=logout_url};Drupal.fbconnect.reload_ifUserConnected=function(state){var user=Drupal.settings.fbconnect.user;if(!state.session||user.uid)return;if(state.session.uid!=user.fbuid)window.location.reload()};Drupal.fbconnect.initLogoutLinks=function(context){var loginout_mode=Drupal.settings.fbconnect.loginout_mode,user=Drupal.settings.fbconnect.user,basePath=Drupal.settings.basePath,logout_url=basePath+'logout',links=$('a[href='+logout_url+']',context).not('.logout_link_inited');if(loginout_mode=='manual')return;links.addClass('logout_link_inited').click(function(){var fbuid=FB.getSession()&&FB.getSession().uid;if(!user.fbuid||user.fbuid!=fbuid)return;if(loginout_mode=='auto'){Drupal.fbconnect.logout()}else if(loginout_mode=='ask'){var t_args={'!site_name':Drupal.settings.fbconnect.invite_name},buttons=[{label:Drupal.t('Facebook and !site_name',t_args),click:function(){this.close();Drupal.fbconnect.logout()}},{name:'cancel',label:Drupal.t('!site_name Only',t_args),click:function(){this.close();Drupal.fbconnect.logout(true)}}],dialog=new Drupal.fbconnect.PopupDialog({title:Drupal.t('Logout'),message:Drupal.t('Do you also want to logout from your Facebook account?'),buttons:buttons})};return false})};Drupal.fbconnect.DoFastRegistration=function(link){FB.login(function(response){if(response.session&&/email/.test(response.perms))window.location.href=link.href},{perms:'email'})}
Let me know if you need any other details. Other than these hiccups, the module works brilliantly.
Comments
Comment #1
alexweber commentedthanks for letting me know, will check it out
tell me this though: do you notice if you get these errors mostly on admin pages or all pages?
Comment #2
webfunkin commentedall pages.
Comment #3
alexweber commentedthanks, gonna check it out! I made a bunch of small improvements in the dev release was waiting for a good excuse to release as a new official version, fixing this bug sounds about right! ;)
Comment #4
alexweber commentedI couldn't replicate the problem 100% but I identified a possible issue that could be causing this and fixed it.
New released 1.3-beta greatly improves compatibility and adds a couple enhancements too.
Please check it out and let me know if it fixes your issue! Thanks!
Link: http://drupal.org/node/1137274
Comment #5
webfunkin commentedSo the problem with hoverIntent is fixed. Or atleast I am not able to replicate it now. So yes, compatibility is much better.
I saw the script section today. I see that first you are loading jquery then as a callback, the rest of the scripts are being loaded. Were you doing the same originally or is that something new? Curious.
Anyways, the original issue has not been resolved. I am still getting the same "jQuery is not defined" error for that piece of code
I am not sure, but will it help if that line is wrapped around a heady.ready(); ? like this :
Comment #6
alexweber commentedYeah, that part is new. Instead of relying blindly on head.js to load in parallel and execute in order I now execute first jQuery and then Drupal.js and then everything else. It fixed the occasional glitches I was experiencing in admin areas.
I'll take another look at the fbconnect module to see what gives but yeah, definitely, wrapping the code in head.ready might probably help!
Keep me posted and THANKS!
Comment #7
webfunkin commentedAh, that approach will probably fix a lot of dependency issues. And the replace scripts in content feature just makes the module a bit more awesome!
Look into the fbconnect module. Although as far as I can see, it does not break any functionalities. It would be nice if I can get rid of all the errors. If you come up with a fix let me know.
There is this part in the HeadJS module :
Can you tweak it (or add another method) to include settings in $closure? As usual I am not sure if it will help (cos my php or Drupal skills are not that great).
Comment #8
alexweber commented@webfunkin np would you mind explaining why exactly you want settings in $closure?
Comment #9
webfunkin commentedI don't want settings in closure. I want the settings (i.e the jQuery.extend(Drupal.settings.....)) part of the closure to be handled by your module. This, because I think fbconnect is adding that problematic line of code in closure which is not being wrapped around a head.ready(); while the one being spit out by the $scripts variable in the theme, is (being wrapped around).
So basically, if any other module were to add Drupal.settings code in the closure, headjs should be able to handle them.
Comment #10
alexweber commented@webfunkin ohhhhhhhhh, ok done! (I actually did this last night when testing with Google Analytics, it just seemed like a good idea lol) will release 1.3-beta2 in a couple minutes and i'll post the link here when it's ready!
UDPATE: BETA 2 is here http://drupal.org/node/1138668
Comment #11
webfunkin commentedFIXED! *high five*
Thanks a lot for your time and all the effort you put into developing the module!
Comment #12
alexweber commentedSWEET!
Thanks a lot for testing it!!
I'm gonna release 1.3 stable in a few hours.
Comment #13
marcus178 commentedI seem to be having this problem in the new 6.x-2.0-beta1 version but I'm using Drupal for Facebook rather than fbconnect.