drupal_add_js() is the function used for adding JavaScript to a Drupal page.
0
votes
0answers
27 views
drupal_add_js in input filter
I have a module that provides an input filter for Drupal 6 and 7. It renders some elements using a (heavy) JavaScript module that I don't want to include on every page.
In Drupal 6 the input filter ...
0
votes
0answers
22 views
Page specific js despite loading pages with ajax
I am currently building a small site which loads menus and content using ajax (which works), however I can't find a way to add additional scripts to specific pages.
Usually I would add the js.script ...
0
votes
1answer
41 views
drupal_add_js not work in form validation failed
I add js file with drupal_add_js in hook_form_alter, it is ok and I see it in list of js loaded in page, but when I submit form and form not validate and return to that form (after validation failed) ...
0
votes
0answers
22 views
Passing an object to settings using drupal_add_js
I'm working on a module that will generate a graph using Google's chart api. The data used to generate the chart uses date objects because I'm graphing race times, like this
[
['Number', ...
0
votes
1answer
69 views
drupal_add_js and variables into anonymous functions, objects undefined?
Pulling my hair out. Read a lot of stuff about scopechain and closure to tackle this one myself. And as i understand at some level, i can't get this to work.
I wrote a module for likebuttons (like ...
0
votes
0answers
30 views
Not able to pass PHP variable to JS file [duplicate]
Javascript works fine, but i need to get my_var variable from module. At the moment its not working.
Clear my page cache and browser cache several times.
The variable 'my_var' is showing value on ...
0
votes
1answer
170 views
How to pass PHP variable to javascript in Drupal 7
Javascript works fine, but i need to get my_var variable from module. At the moment its not working.
Clear my page cache and browser cache several times.
The variable 'my_var' is showing value on ...
0
votes
0answers
27 views
How can I trigger a call to a custom module function before the browser unload event?
I have built a report for an client account that shows payments and charges with totals. I am now adding an export button using the PHPExport module.
As I already built the data to display in the ...
0
votes
2answers
153 views
Passing Settings from Drupal Module to Javascript: Uncaught TypeError: Cannot read property
In my module I have the following code.
$my_settings = array(
'basePath' => '/',
'my_locs' => $my_locs // Array of numbers
);
drupal_add_js(array('my_module' => $my_settings), ...
0
votes
1answer
34 views
How to desactivate jquery_update logic for the homepage
The objective of this is to remove all legacy javascript files from the homepage except for the new javascript files I specifically want to load.
Here is how I remove all the Javascript files I don't ...
3
votes
2answers
783 views
is it good idea to add js file for every page?
I have some JS and CSS on my site that are very specific to some pages. From a Drupal perspective, it is good idea to add them using drupal_add_js() instead of THEME.info? Does such thing affect ...
0
votes
1answer
188 views
Drupal #attached doesn't work with some themes
I've written a module which loads CSS and JS files using the #attached property. This works fine across most themes, but for some themes the files are not loading.
e.g.:
...
0
votes
1answer
73 views
What should be the path to the file while using #attached in a custom_module_block_view()?
I have created a custom module and was trying to add javascript file to a block using #attached method which was described here. I am confused with the Path/to/file as I have tried to give a full path ...
-1
votes
1answer
80 views
Using Drupal Default jQuery only on node form?
I need to use the jQuery 2.0 in my drupal 7 site, so i have unset two drupal jQuery files and added the latest version of jQuery using this code in my template.php file so it will not affect the views ...
0
votes
1answer
49 views
Push Items to Array using drupal_add_js
I'm using this code in a for loop to push items to an array but it doesn't add to the array, just overwrites it each time I think:
drupal_add_js(array('THINGS' => array('ONE' => array('VAR' ...
-1
votes
1answer
678 views
1
vote
1answer
144 views
How to add_js per content type in my module?
I'm looking for a way for my module to evaluate the content type in a preprocess hook and conditionally add some javascript.
Theme_preprocess_page() makes the content type accessible plus some ...
5
votes
4answers
1k views
Adding JS to a Drupal 8 theme (replacement for drupal_add_js)
In Drupal 7, I can use drupal_add_js within a theme's template.php file as a theme_preprocess_html(&$vars) function:
drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/scripts.js',
...
0
votes
2answers
58 views
How to use Drupal.behaviors in Drupal 7?
I have these codes in my druapl 7 theme js file (js/test.js):
(function($) {
alert("Hi");
Drupal.behaviors.mythemename = {
attach: function(context, settings) {
alert("Bye");
...
2
votes
2answers
303 views
Adding a jQuery UI widget in the administrative front-end
I have created a form within the administrative front-end in my Drupal 7 site to allow administrators to change some configuration options. I've defined the path to it in the following way (in ...
1
vote
1answer
373 views
Difference between theme.info and drupal_add_js ( jquery-2.0.3 )
On a fairly new drupal (7.23) site I tried including the jquery-2.0.3.js file with the drupal_add_js function in one of my modules hook_init function. All was working good and well when I was testing ...
1
vote
1answer
170 views
Autofill fields on profile form based on previous fields
I have a particularly long user profile form on my client's site. Some of those fields can be autofilled using information already entered (such as spouse last name). The filling out needs to be done ...
6
votes
1answer
204 views
what is the difference between using drupal_add_js and ['#attached']
What is the difference between drupal_add_js() and $form['#attached']['js'][] ?
When is the purpose of using each of the above functions?
(I mean I know that it is used to attached js to say form if ...
0
votes
2answers
228 views
JavaScript supposed to always be called on front page, but doesn't always run
I have some JavaScript that is called on the front page, and is supposed to execute. When I go the page initially, it works fine. Then if I go to another page, then come back, it doesn't show. It ...
0
votes
2answers
50 views
How to load one certain js before all others?
We are struggling around here with SVG in IE8. Amongst other approaches we'ld also like to try the SVG Web Toolkit. In it's quick start guide they say:
To use SVG Web, you must drop a script tag ...
3
votes
1answer
301 views
How to add data to Drupal.settings without drupal_add_js
Is there any way to add some variables to Drupal.settings without drupal_add_js (with setting argument).
I'm creating a site that has a custom ctools popup style but I'm not feeling good with ...
2
votes
1answer
99 views
Including JS files in template.php to control weight/order/group
I'm looking to include a few JS files (some libraries, others are custom modules with dependencies on libraries). Originally I had all JS files added through our .info file, and while I could control ...
0
votes
2answers
155 views
How do I apply cufon.js only for Internet Explorer, in template.php?
I have some font problems in Internet Explorer, so I am trying to apply font-family through JavaScript. It works, but the JavaScript code runs for every browser.
How do I run JavaScript code only on ...
1
vote
1answer
206 views
A lot of core JavaScript files not being included
For some reason a bunch of core JS files are not being loaded. I've had to manually add them in with a module hook_js_alter function like so:
function MYMODULE_js_alter(&$js) {
...
1
vote
0answers
124 views
Autosubmit for exposed filters and .appendTo
I want the combobox to my self send exposed filter, I have no problem there it succeeds to do with .change, the problem is that these combobox need them in another div outside the container exposed ...
0
votes
1answer
126 views
Add js script to register page
Like the title says really, I'm trying to add a script to my register page, I'm using Zen as my theme, and I've added a script into the .info file, and to just test that it works I have added an ...
0
votes
1answer
630 views
drupal_add_js only once
I have a field which is used in a nodeblock, and only appears on a few select pages. This however will vary throughout the lifetime of the website so I've been looking for a way to insert the ...
0
votes
2answers
822 views
Adding JavaScript before drupal.js
I am trying to add jQuery to my page (it is not being added by default). The file is adding to the page but after drupal.js causing the error:
SCRIPT5009: 'jQuery' is undefined
drupal.js, line 5 ...
0
votes
2answers
334 views
Drupal javascript file loading and jQuery
I have several javascript files in custom modules containing many functions which are used across the code. In D6 I simply added them during hook_init() and it was fine.
...
0
votes
2answers
294 views
JS Javascript into a single node / page
I have a form that works fine outside of drupal where it called a script ..../default.js However this does not work inside drupal 6 when i copy the code from ym html/php file.
I have seen this line
...
0
votes
2answers
329 views
Does aggregating JS/CSS interfere with my drupal_add_js()?
I want to use drupal_add_js and drupal_add_css on a per-page basis so I have added a 'scripts' text field to my basic content type and have set the Format Type to PHP.
It works beautifully until I ...
0
votes
1answer
413 views
Setting a Drupal.settings JS variable from a form field
i'm working on my first custom module and really fumbling along :). thanks in advance for your advice!
goal
i've added a checkbox to the comment form. if the user leaves it checked, then following ...
0
votes
0answers
46 views
Addng Javascript files
Another question for you guys. Let me first explain that I am adding javascript files the way I think they are supposed to be added, by putting them in my template file using drupal_add_js. However, a ...
3
votes
3answers
7k views
How to get jquery working on Drupal 7 - for Newbies
I have been reading many tutorials online on how to get jquery working on drupal 7.
Although there are many lines of code and examples, what i cannot find is what piece of code to put where (maybe it ...
2
votes
2answers
836 views
drupal_match_path() for multiple wildcard patterns?
I want to add some CSS and JS to multiple matched wildcard URL patterns. According to Add javascript to multiple specific urls, I can use a wildcard using drupal_match_path() and that works well for ...
-1
votes
2answers
125 views
Javascript cost calculator
I used JavaScript to construct my calculator, and I'm wondering how to get it to work.
I've tried drupal_add_js(), but it didn't work. I've tried two different modules that incorporate JavaScript, ...
0
votes
1answer
2k views
Having trouble adding a custom js file to my Drupal 7 site
I added a javascript file to my site in the theme's .info file
scripts[] = js/myjs.js
The js file loads and I can see that it's included in the head when I load the site, however the jQuery ...
2
votes
1answer
1k views
drupal_add_js() won't work with footer scope
i 'm trying to add a file to end of body via template.php in mytheme_preprocess_page.
this is the line i have:
drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/file.js',array('type' => ...
0
votes
1answer
241 views
JS Resize function for div containing a a slideview slideshow and set as a page background
This is for a drpal 7 install.
Is there a way to apply the same function they discuss in this thread
...
1
vote
0answers
133 views
drupal_add_js setting does not work in admin overlay
I do a form alter for the node edit form (hook_field_widget_form()). Within this alteration I add some settings to the Drupal.settings object with:
$settings = array(
'custom_api' => array(
...
1
vote
1answer
165 views
Generate js variable before javascript loaded
I have a block with invocation code inside(it invokes js code from OpenX ads server), my site is responsive and this block get cloned(with jquery .clone() function) on ipad or iphone version of the ...
1
vote
3answers
673 views
Add Google Analytics JS file to every page
We use Google Analytics on each of our sites for our own reporting. We have implemented GA using the Google Analytics module, and everything works as expected.
However, I'm also part of a large ...
0
votes
2answers
978 views
overlay does not work after enabling my custom module
I am using latest Drupal 7.
I just noticed my admin overlay is not working.
First I thought its due to Jquery Update contrib module installation however that not it.
Its apparently due to my ...
3
votes
0answers
3k views
TypeError: jQuery(“#mycarousel”).jcarousel is not a function [closed]
I added this jQuery function to my drupal7 header for jcorousel plugin.
<script type="text/javascript">
jQuery.noConflict();
(function($) {
$(document).ready(function() {
...
0
votes
0answers
320 views
drupal_add_js() includes JS with wrong weigth
A module I am using on my site uses the drupal_add_js() function to include some JavaScript. Although the function is used correctly the JavaScript file is included before the jQuery script which ...