I am having a bit of trouble figuring out how to call a javascript function I have in a node template.

The flow I am trying to achieve is a user clicks a link (its a link which activates the colorbox module). This then loads a node template with a video and my custom javascript function I want to call. Then when the user closes the colorbox a callback is made which should then call my custom function.

I have a general javascript file loaded into my omega theme which listens for the colorbox link and on the close callback I want it to call the function defined in the called node.

The javascript in my functions file is:

(function ($) {
Drupal.behaviors.l_d_links = 
    attach: function (context, settings) 
            onCleanup:function(){ dbUpdate(); }

And javascript code in my node is:

function dbUpdate() { console.log("start $.post"); }

Just to add the reasoning behind putting the function in the node template is because I need access to some php variables on node load. Is something like this possible?

  • Just got home and fired up my home PC to try and troubleshoot, however the code is working now o.O – inertiahz Jul 6 '12 at 19:13
  • could you please post your answer and check it as the solution. It will help our community :) – cayerdis Nov 24 '12 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.