I have an external file being loaded via template.php using the following code:

function digital_dots_preprocess_views_view(&$vars) {
  $view = $vars['view'];
  if($view->name == 'work') {
    drupal_add_js(drupal_get_path('theme', 'digital_dots') . '/assets/scripts/fx.js');

The JS file is being loaded with the following code:

(function ($) {
    //alert('It works!');
})( jQuery );

Un-commenting the alert will trigger the alert however the hide effect doesn't?

Very confused!

  • Hi, this is a general problem with your jQuery code, nothing to do with Drupal. It's already been addressed a number of times on this site so there's no point in keeping another version of the same question around. Read up on jQuery.ready and you'll have the answer :)
    – Clive
    Oct 5, 2013 at 12:26

1 Answer 1


If you are getting alert from the JS file than it means your JS file is loading properly, and the problem of hide seems to be causing because hide to be called in the document.ready as following:

// Jquery wrapper for drupal to avoid conflicts between libraries.
(function ($) {
  // Jquery onload function.
  $(document).ready(function() {

Not the answer you're looking for? Browse other questions tagged or ask your own question.