Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In the page.tpl.php template file, I have the appropriate print $scripts;
call in the HEAD tag. I tried using the example code (below) at the beginning of the file, but it doesn't work, even after clearing the cache.
<?php
echo '<div class="countdown">10 seconds!</div>';
jquery_countdown_add(".countdown", array("until" => 10, "onExpiry" => "finished"));
drupal_add_js("function finished() { alert('You are done!'); }", 'inline');
?>
I looked into the Drupal.settings code in the header, and I do not see the typical jquery_countdown definitions.
Comments
Comment #1
chadhester CreditAttribution: chadhester commentedScratched my own itch. It appears that the best method (in page.tpl.php) is with the jquery_countdown_add() function. But after that, the $scripts variable still isn't updated, so before I call that in the HEAD, I update it with:
$scripts = drupal_get_js();
Because of this, I don't think that using jquery_countdown_add() function after the $scripts variable has been called is a good idea.
Comment #2
chadhester CreditAttribution: chadhester commentedclosing this, since there's a legit workaround