A drupal function used for adding JavaScript to a Drupal page.

learn more… | top users | synonyms

0
votes
2answers
27 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
45 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
29 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 ...
1
vote
4answers
54 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 ...
1
vote
2answers
55 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 ...
0
votes
2answers
77 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
79 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 ...
1
vote
1answer
92 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
0answers
21 views

Calculations in a custom content type that display in saved content

Drupal 6.28, custom content type. I need to have users select numbers (possibly with attached text, e.g., 3 - meets expectations, 3.5 - exceeds some expectations) from two or three select lists (how ...
0
votes
1answer
90 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 ...
0
votes
0answers
63 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
55 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
148 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
247 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
776 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
80 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 ...
3
votes
1answer
123 views

Is there advantage to using Drupal.settings, as opposed to directly passing json-encoded var to javascript function

Inside my custom views template, views-view-myview.tpl.php, I have a variable ("$myvar"), which I need to pass to a custom javascript function. Here is how I am currently doing it: A. json-encode ...
1
vote
0answers
418 views

How to use an external jQuery plugin with Drupal's no-conflict jQuery

I'm using drupal_add_js() to load some external js: drupal_add_js('http://jquery-accordion.googlecode.com/svn/trunk/jquery.accordion.js', 'external'); This produces 'TypeError: $ is not a function' ...
1
vote
0answers
59 views

Why won't JS fire on ubercart checkout page and how do I fix?

I need some custom JS (jQuery to be precise) to run on ubercart's /cart/checkout page. I turned off JS optimization and tried adding it to several different files that are already loading and the JS ...
1
vote
1answer
1k views

Adding jQuery to Drupal 7 site: drupal_add_js() adds but doesn't call?

I'm using jQuery accordion effects to display some information. I include the libraries: drupal_add_js('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', file); ...
3
votes
3answers
317 views

Conditional drupal_add_css and _js are adding code to every page

I am trying to add a CSS and JS files when a certain content type is being viewed (Drupal 6). The problem is that the code is being added to every page. I have tried this first, included in ...
1
vote
1answer
542 views

How is JavaScript included in Drupal 7?

My site is built on Drupal 7, and a number of my .js scripts are throwing this exception: Uncaught TypeError: Property '$' of object [object Window] is not a function. After some research, I think ...
0
votes
2answers
780 views

Possible conflict with multiple jquery plugins

I have a custom module that uses the jCarousel jquery plugin (not the Drupal module). The module code up to this point works correctly, and looks like this (only the main function included for ...
0
votes
2answers
252 views

adding javascript in html.tpl

I am trying to add js in footer drupal_add_js(drupal_get_path('theme', 'mytheme') .'/js/libs/jquery-1.7.1.min.js', array('type' => 'file', 'scope' => 'footer')); but with some reason it is not ...
0
votes
2answers
345 views

drupal_add_js() 'setting' not being set on form submit

I have a form and on that form the #submit action it calls a function that saves some data. Now what I need to do is I need to pass some data back to the website confirm page to be used by ...
-1
votes
1answer
166 views

How to have Menu like apycom

How can I create menus like Apycom Menus ? Do I need to create custom module and then use it which will be available to whole site or I can just use css and js from the apycom menus?
7
votes
5answers
433 views

Unable to add JavaScript on a page

I am using this, but I don't understand why it's not working. if ($_SERVER['REQUEST_URI'] == '/node/1') { drupal_add_js(drupal_get_path('theme', ...
2
votes
1answer
98 views

What is the purpose of url('', array('prefix' => &$prefix)) in drupal_add_js()?

I was looking at the code of drupal_add_js(), and noticed the following code. // url() generates the prefix using hook_url_outbound_alter(). Instead of // running the hook_url_outbound_alter() ...
1
vote
4answers
222 views

Add a JavaScript file without ?hash

Is it possible? I am trying to include a JavaScript plugin that works incorrectly when path is /script.js?hAsh.
0
votes
2answers
121 views

Added js file is not working nor throws it any errors

I add a js file with form_alter and #attached. Everything works fine. function ganzech_form_alter(&$form, &$form_state, $form_id) { switch ($form_id) { case ...
0
votes
0answers
595 views

jquery ui not found in drupal 7

although jquery ui goes to core of drupal 7 , but when we use a plugins like sortable or draggble it return error to us, in drupal 6 we have this jquery_ui_add(array( ...
3
votes
3answers
2k views

How to unset javascripts in Drupal?

I wanted to unset some javascripts since they does nothing but conflict on my custom JS in my mobile theme. What I did: // Load all js scripts $scripts = drupal_add_js(); // Unset all ...
1
vote
1answer
197 views

Drupal behaviour function not getting executed

I defined a simple block on my module, using the following code. function visita_virtual_block_view($delta = '') { switch ($delta) { case 'mapa': $path = ...
0
votes
2answers
176 views

How can we find the js file is included before or not in drupal

I have some functions in template.php file that inside some of them, some js files must be included to the template. Now, I want to check at first whether a specific js file [for example ...
0
votes
2answers
514 views

How to iterate through Drupal.settings in a js file when there are lots of variables?

Am trying to create a health service locator using Google maps API on my Drupal 7 site. (FYI, I cant use location module or open layers, because, Create a hospital locator in drupal 7 ) OK, so now I ...
1
vote
4answers
136 views

Change JSO(N) parameters that have been set by another module

I am trying to override parameters that have been set by another module. The other module uses drupal_add_js() to set the parameters. $settings = array('color'=>'red','type' =>'round'); ...
0
votes
2answers
374 views

drupal_add_js causes blocks to be executed twice

I added this code to template.php (in Zen subtheme): function mytheme_preprocess_page(&$vars) { if ($vars['is_front']) { drupal_add_js (libraries_get_path('jquery.cycle') . ...
0
votes
2answers
217 views

How to restrict JS applied to a block only to block visible pages?

I am using Drupal 6. I have added the javascript to my block using hook_theme as shown below. function theme_custom($text) { drupal_add_js(drupal_get_path('module', ...
0
votes
2answers
883 views

How to include js file in a module which depend on jquery?

I have a module called catalog_menu I included a js file within this module in this way: drupal_add_js(drupal_get_path('module', 'catalog_menu') . '/js/catalog_menu.js'); Now in the browser I get ...
1
vote
4answers
3k views

drupal_add_js in html template file

I am using a zen subtheme and I am trying to add some javascript using the drupal_add_js on a certain node. When I use the drupal_add_js from within the html--node--XX.tpl.php file, it does not work. ...
3
votes
1answer
582 views

drupal_add_js cannot find my javascript file

I am trying to add a simple footer.js to my page. I created a new block and put it in the footer. I then use PHP snippet in the body of the block with the PHP code: <?php ...
1
vote
2answers
232 views

Why is an integer variable in PHP interpreted as a string literal when passed from Drupal to JavaScript via Drupal.settings?

This is in Drupal 7. I'm attaching some JavaScript via drupal_attach_js(), using "settings` to be able to pass the "height" parameter to a JavaScript function. The height is used in a modal dialog, ...
3
votes
1answer
299 views

drupal_add_js(), script not executed

I try to include a simple script (below) and cant get it to work. (function ($) { Drupal.behaviors.myModuleBehavior = function (context) { alert('say something pretty please'); } })(jQuery); ...
2
votes
2answers
132 views

use drupal_add_js for file outside drupal dir

I would like to add a js file thats outside my drupal installation dir, but keep it relative to that dir. mysite |-- drupal |-- dirWithJsFile |-- thisfile.js i have already tried things ...
2
votes
2answers
1k views

custom module: drupal_add_js and drupal_add_css do not work after form validation?

I have created a custom module that changes the layout & adds extra functionality to one of my content type creation and edit forms. It works beautifully and as expected apart from when I submit ...
2
votes
4answers
9k views

How to auto resize the height of an iframe with Jquery?

Any idea on how to automatically resize the height of an iframe based on its content. The iframe source is coming from different domain. Any thoughts on how to achieved it via Jquery or native JS? ...
1
vote
1answer
667 views

Form API, drupal_add_js() and setting a JS variable

Consider drupal_add_js(array( 'radio86_media' => array('barfoo' => 'booboo')), 'setting' ); and $form['#attached']['js'] = array( drupal_get_path('module', 'radio86_media') . ...
4
votes
2answers
328 views

Weighting Javascript in .info files

Drupal 7 adds a new 'weight' option to drupal_add_js so that you can control the order in which Javascript files are added to the page. Is there any way to do this when adding Javascript in .info ...