Adding jquery to views output

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
styles24's picture

I am interested in installing this jquery function: http://desandro.com/demo/masonry/ to my taxonomy terms page, which is being displayed by views, I have already added the .js file to my .info theme file. The javascript loads fine, but I seem to be lost on where I should put the

$('#primary').masonry({
columnWidth: 100,
itemSelector: '.box'
});
for example.
I've already tried placing the code in the output of the views field but the effect still doesn't work. What do I seem to be missing or doing wrong?

Comments

Hi try to put the code into

Ivo.Radulovski's picture

Hi try to put the code into the specific views tpl file if you need this only inside this view you can declare the js file here too. If you need more details just ask :)

-----

Drupal Development by Trio Interactive

Another way to do it is to

Garrett Albright's picture

Another way to do it is to create a new JavaScript file and add it to your theme the same way you did with the Masonry script. This section of the Drupal development guide should be of interest.