Reputation: 23
I'm tryng to run a simple script for an accordion button on Drupal 7.
I had the script tested on a local machine using module "Display suite" allowing me to add custom javascript inside drupal content, and it ran smoothly.
Now I won't be able to use the module on my server so I put the script inside my custom theme, inside the site/all/themes/my_theme/js where a default "script.js" file already loading on all my pages exists, but the script doesn't work any more (the one for my button, the file script.js loads fine).
I'm trying to find a solution using the drupal doc (digging into the drupal_add_js() for now), but as a javascript noob it would greatly help to understand why and how drupal proceeds a script "inside" content differently from external scripts.
Thanks !
Upvotes: 1
Views: 41
Reputation: 23
Okay I have found my solution. Drupal is adding a few <p>
and <div>
elements on some specific HTML elements (<button>
in my case) when changing the text format to "Full HTML", thus destroying mercylessly my script.
So to anyone else wondering:
why and how drupal proceeds a script "inside" content differently from external scripts ?
Drupal doesn't proceeds it differently (it does read it after the HTML content if you put it at the far end of content for performance).
Upvotes: 1
Reputation: 1826
i guess you forgot to include the script inside of your my_theme.info.
this file is located: site/all/themes/my_theme/my_theme.info
you have to include scripts[] = 'js/my_new_script.js'
dont forget to clear your cache.
Upvotes: 1