0

I would like to use the whole tease as a link to the node. I could google (and adapted) the following code but still not working.

following line: scripts[] = js/new_teaser.js is added in the ".info" file of my theme (Business) and this code to the "new_teaser.js":

$(document).ready(function(){

    $(".node-teaser").click(function(){
      window.location=$(this).find("a").attr("href"); return false;
    });

    });

the class of my teaser is ".node-teaser" and the "NoScript" addin of my browser is switched off. I assumes that the problem is in the JS code.

Drupal 7, theme Business

Could someone help me please?

EDIT: as far as I can see, there is no link to the new_teaser.js file in the source code of the page... (even if the file is in the js/ folder and in the theme .info file

  • Though I don't think you should do it this way, have you tried clearing cache? – kyletaylored Sep 11 '13 at 2:42
  • Of course, cache cleared, cron ran... – DataSmarter Sep 11 '13 at 4:41
  • I found that soution here: drupal.org/node/606758 but it doesn't work for me... – DataSmarter Sep 11 '13 at 4:48
0

Something like this should work. Add it to your template.php file. Using preprocess_node gives you a little more control so you aren't just arbitrarily loading the script on every page.

function THEMENAME_preprocess_node(&$variables) {
  if ($variables['type'] == 'blog' && $variables['view_mode'] == 'teaser') {
    drupal_add_js($theme_path.'/js/new_teaser.js');
  }
}

Your Answer

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

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