When I enable Labjs, the AddToAny module stops working.The same problem exists for the HeadJs module as well.

CommentFileSizeAuthor
#6 addtoany.patch700 bytesjcisio
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

Can you check again with the latest snapshot of LABjs (31 Jul)?

kurtzhong’s picture

But my I am using drupal 7.4, and the version you mentioned it for Drupal 6.
Because the AddToAny module has two inline scripts, one in the header and one in the footer respectively. If the Labjs could exclude them from the chain, I think things will be ok.

jcisio’s picture

I push the changes yesterday but I don't know why there is no new developement snapshot in 7.x branch yet. The changes are in http://drupalcode.org/project/labjs.git/commit/4c5e58a and http://drupalcode.org/project/labjs.git/commit/e4544d4

jcisio’s picture

I've found the problem. 7.x-1.x-dev was tracking in the master branch that I stopped on it for a while and switch to 7.x-1.x branch. I fixed it. Hope a new snapsnot will be available soon.

kurtzhong’s picture

Thank you jciso. I've checked the latest snapshot, but still not working. There's a inline js code output from AddToAny module which is not captured by Labjs, and it shouldn't executes before other two inline javascripts on which it depends.

jcisio’s picture

FileSize
700 bytes

The following patch for addtoany will have inline script wrapped by LABjs. Well, it also a more D7-way to insert inline script.

But the way that AddToAny use async to do several attempts to load the script make it difficult for LABjs to intervene. I'll debug a little bit further.

jcisio’s picture

Title: Incompatible with AddToAny module » Incompatible between LABjs and AddToAny module
Project: LABjs » AddToAny Share Buttons
Version: 7.x-1.1 » 7.x-1.x-dev
Component: Compatibility » Code
Category: bug » feature

The problem is that when inline script is wrapped by LABjs, variable scope change.

$L = $L.wait(function() {
  var a2a_config=Drupal.a2a_config||{}, da2a = ...
});

After that block, a2a_config and da2a is no longer available. There are two solutions:
- Wrap them into Drupal (like Drupal.a2a.config = ..., Drupal.a2a.d = ...)
- Put them into a JS file (like the case "Drupal" variable is put into misc/drupal.js).

I'm sorry to pass this issue into a2a. But it's a more "Drupal way" to do ;-)

kurtzhong’s picture

So appreciated to see your patch on a2a and two constructive solutions. Although it's not working yet, I don't see the 'da2a not defined' error anymore. I am not good at javascript and know little about drupal's js mechanism, but you really help me with understanding this issue a lot. Thank you very much :)

kurtzhong’s picture

Issue summary: View changes

Updated issue summary.