With the great help of Sk8erPeter I managed to execute Javascript code on node creation and node update of a certain content type in Drupal 7.
My problem now is that I can not call the function FB.api from withing this modules js files. Does it have something to do with Javascript namespaces? Running the FB.api() function from console works fine...
Thanks in advance for any help.
Nils
Based on your comments... I'm just watching your
testModule.behaviors.js
, and it doesn't even look similar to the function that I wrote to you here in the other topic.Your current code is only like this:
Where is
Drupal.behaviors
, and itsattach
function I showed you earlier? Where are all the other stuffs? :)It's not even surprising that the current code outputs an error, because I think this JavaScript file is included before even defining the
FB
object, and this way you call this code directly in the header.I think your
testModule.behaviors.js
file should look like this (based on the previous code we were talking about):So REPLACE your CURRENT content (where you are only calling
FB.api
without any Drupal-specific behaviors "wrappers"), and change its content to this one.EDIT:
OK, try to set the weight of this module higher ONCE with the following
db_query()
, so its hooks get invoked later than the other modules' hooks. After putting these lines in your code, save the file, delete the Drupal cache, and after that, comment out the appropriate line! It's not needed to run all the time, in every page loads!