jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions.
25
votes
1answer
15k views
Better understanding of Drupal behaviors
I read about Drupal behaviors today, and I tried writing the following code.
(function ($) {
Drupal.behaviors.mymodule = {
attach: function (context, settings) {
$('#mymodule_id', ...
21
votes
4answers
9k views
How do I change the ajax loading behaviour in Views?
I have a view with some exposed filters in a block; it uses AJAX and the auto-submit feature so the view is re-loaded as soon as a filter option is changed.
In the short delay between selecting an ...
18
votes
5answers
17k views
How do I update jQuery to the latest version I can download?
I'm using Drupal 7, which uses jQuery 1.4 as default? How can I update it to the latest version (currently 1.7)?
13
votes
11answers
15k views
How to add Jquery plugin to Drupal?
Should I just paste the code in the main template file, or is there any other recommended way of attaching new Jquery plugins in Drupal 7?
11
votes
3answers
7k views
Changes in the way Drupal 7 handles JavaScript and jQuery
I'm currently developing a JavaScript script that runs on an administration page. I read up on the changes made in Drupal 7, namely the move from document.ready() to its own jQuery function. However, ...
11
votes
4answers
3k views
Using a newer JQuery version
The Drupal 6 version of jQuery is too old (1.26). Could I delete, and replace it with a newer version?
11
votes
2answers
4k views
Drupal 7 & jQuery — the $ dollar sign
If I'm not planning on using any JS libraries other than jQuery, is there any reason to need Drupal's call to jQuery.noConflict() which removes $ as an alias for jQuery?
Assuming there is no need for ...
10
votes
4answers
2k views
Including a different jQuery version only on specific page
jQuery update module is including this script.
<script type="text/javascript" src="/sites/all/modules/jquery_update/replace/jquery.min.js?6"></script>
I need this on every page, except ...
9
votes
2answers
5k views
How can I use jQuery 1.7 without having issues in the admin pages?
Is anybody successfully running jQuery 1.7?
I'm using a jQuery component on my pages which requires jQuery 1.7 or later. This version causes some unwanted side effects in the admin UI, such as checked ...
9
votes
2answers
3k views
Drupal's attach behaviours : react on all newly loaded content?
I've got two different modules which in many ways work together. One of the things they work together on is that module A loads content via AJAX, and module B needs to attach event listeners to the ...
8
votes
2answers
2k views
Detect front page in Drupal 6 with javascript
Using javascript in Drupal 6, is there a way to detect whether the present page is the front page? I have a custom Drupal 6 module that outputs different javascript codes based on whether the present ...
7
votes
2answers
3k views
Adding JavaScript and CSS to a particular menu page
I have set up a Drupal 7 web site with a few custom blocks and menus written by me.
I have a non-Drupal PHP script displaying users (some of them are external, i.e. not stored in drupal tables) as a ...
7
votes
1answer
4k views
How to load a view with ajax so that additional js/css files needed by the view are also loaded?
Currently I'm using jQuery to load a view, like this:
$.ajax({
type: 'POST',
url: Drupal.settings.basePath + 'views/ajax',
dataType: 'json',
data: 'view_name=' + viewName + ...
7
votes
2answers
577 views
Info on Drupal.settings and #attached
I'm trying to use Drupal.settings for the first time to pass variables from PHP to JavaScript. The documentation on the topic is sparse and I have a few issues.
Is it possible to use #attached to ...
6
votes
2answers
9k views
Force Drupal to attach Drupal behavior to new ajaxed content [only Drupal.attachBehaviors() is not working the right way]
I was doing lot of posts on drupal.org about this topic, but unfortunately in the wrong context.
Ajaxed content is not attaching needed JS and CSS (forum)
Ajaxed content is not attaching needed JS ...
6
votes
5answers
6k views
Programatically trigger a click on an AJAX enabled form submit button
I'm trying to programmatically (with jQuery) trigger a click on button with AJAX behavior in a Drupal form, but so far jQuery('#edit-submit').click() doesn't do anything.
A real mouse click on that ...
6
votes
3answers
4k views
Can I attach a jquery.ui.datepicker widget to a form element using the form api?
I have a generic form element:
$form['date'] = array(
'#type' => 'textfield',
'#title' => t( 'Date' ),
);
That I want to add the jquery ui datepicker to this element. Is there a way ...
6
votes
2answers
587 views
How can I listen for drupalOverlayBeforeClose in custom jQuery?
I am monitoring a particular form for changes and want to warn the user before they attempt to navigate away from the form without submitting it. I've successfully gotten this working in all instances ...
6
votes
1answer
400 views
jquery get or post methods for drupal block module
Is it possible to use jquery get or post methods to fetch data dynamic in a a drupal7.x block module. I am a newbie to drupal.
Here is my event_calendar.module file
function ...
6
votes
3answers
2k views
Help implementing Supersized.js in Drupal 7
I am trying to add Supersized.js into my Drupal 7 site. I have updated Drupal to use the latest version of jQuery, I added scripts[] = js/supersized.3.1.3.min.js to my .info file, and in my ...
6
votes
2answers
460 views
drupal_add_js and drupal_flush_all_caches
I was trying to call drupal_add_js in the callback of a button. It seems, even with after_build, that this can be done successfully only you are working without cached data.
So, before i start the ...
5
votes
2answers
230 views
Converted CSS/HTML theme to D7, .js files ignores integrated jQuery and works only with jQuery imported via .info
I got a basic static CSS/HTML theme which is using some .js like jcarousellite.js and it has a jquery file together which is jquery-1.4.2.min.js
So I import that jcarousellite.js via theme's .info:
...
5
votes
4answers
5k views
jQuery UI theming
I want to use in my module custom jQuery UI theme from the themeroller.
What is the best way to do it?
5
votes
3answers
2k views
How to get the drupal node id from within jquery/javascript?
Is there a definitive, universal way to do this? For example using an 'environment' variable that comes with Drupal.behaviours?
Have done some research and there doesn't seem to be a common answer.
5
votes
4answers
3k views
How to get full page width background slider
I am working on a drupal site, now my requirement is I need to slide the background images with fade effect on the home page.
Is there any module to get this effect?
Please suggest me if we can get ...
5
votes
3answers
898 views
How can I slideDown with #states?
I have a form using "#states" (in the Relation module), and it works, but it kind of jumps around. A nice slideDown would be so much better.
How can I do that instead of just making it visible?
5
votes
4answers
2k views
Get this jQuery Youtube Playlist working?
Drupal 7. I'm trying to get this to work - seems simple enough. I added the .js file through my theme's .info file, and it's picking that up. I selected "Full HTML" as the format for my block, and ...
5
votes
3answers
1k views
Views Slideshow vs list View+jquery cycle lite?
The rotating images on my work site's home page are created as a View in list format. I'm using the jQuery Cycle Lite plugin for the rotator effect. The cycle.lite.js file is set in the scripts array ...
5
votes
2answers
3k views
What should I do to use a more recent jQuery version?
I am trying to use this jQuery Bubble script plugin with my Drupal 7 site. The plugin requires Jquery 1.6.2 (Drupal 7 only comes with 1.4.4).
There are some solutions on the net but none seem to ...
4
votes
2answers
8k views
How to add JavaScript to my Drupal site?
I am new to Drupal. I have knowledge of JavaScript and CSS. I googled, but I did not find an explanation on how to add JavaScript to my site. How can I add JavaScript and CSS to my site? Are there any ...
4
votes
3answers
3k views
Get the latitude and longitude from the user ip
I am trying to get the latitude and longitude from the user who connected to my website to draw or show his position on a map, but it showed him in the wrong postion. Is there any way to get the ...
4
votes
2answers
5k views
Listen to AJAX complete event from a behavior
I have a form that has an AJAX button. When I click it, it updates a bunch of stuff as expected which is fine.
I was wondering if there is a way to create a listener in behavior that gets called ...
4
votes
3answers
2k views
How can I disable jquery_update when my admin theme is in use?
I have installed jQuery Update but it breaks some core functionality that makes the admin UI a struggle to deal with. Is there a way to keep jQuery Update enabled but disable it when the admin theme ...
4
votes
2answers
887 views
console.log() renders elements as “D.fn.D.init”
I have a strongly ingrained habit of using console.log() to pinpoint where an element is on the page. Usually if you had a page like this
<html>
<div>hello Drupal.stackxchange.com ...
4
votes
4answers
5k views
Update jQuery in Drupal 7 without breaking views and other modules [duplicate]
I need to use jQuery 1.8.3 for some functionality I need but when I use the jQuery update module to go to 1.8 other modules stop working including views. This is obvioulsy not gonna work.
Is there a ...
4
votes
2answers
773 views
How to properly specify context for Drupal behaviours
I have this code that does not work. I know why it does not work - first time page is loaded 'context' is all page and jquery easely finds '.view-SPECIFICVIEW .view-content'. After AJAX 'context' has ...
4
votes
4answers
4k views
In Views, how to wrap a div around every specified number of items
I'm using D7, Views 3, and am playing around with using jQuery Cycle. What I would like to do is amend my view output so it's like in this example from the jQuery Cycle website:
<div ...
4
votes
1answer
10k views
Controlling the height of a jQuery accordion in content page
I have managed to add a jQuery accordion content page to my Drupal7 site by following the instructions/code given here: http://www.chrisherberte.com/blog/drupal-7-and-jquery-ui-accordion.
However, ...
4
votes
1answer
705 views
Drupal 7 views admin redirecting to json returned after changing jquery version
I have installed the seven theme on the admin side and blocks theme on the user side...
after getting alot of errors from multiple files adding jquery library, i have removed the extra files and ...
4
votes
1answer
3k views
How to use URL-based AJAX in Drupal 7 to serve all pages?
I know this can be done through jQuery alone, but I'm interested in knowing if there any Drupal 7 ways of achieving this:
I want to use AJAX to serve all non-admin pages on my site. Also I don't want ...
4
votes
2answers
812 views
How to trigger JavaScript/jQuery on AJAX-enabled ImageField submit?
I'm trying to trigger a JavaScript event when an AJAX-enabled ImageField submit button is clicked.
I've tried variations on delegate(), submit(), and click(), but no joy.
This is something similar ...
4
votes
1answer
2k views
Jquery and Drupal Autocomplete
I have an autocomplete field in a custom form which works and returns a pipe-seperated value which I want to then split up and insert into the appropriate form fields.
For example, the autocomplete ...
3
votes
3answers
12k views
Using jQuery to communicate to Drupal 7 via AJAX
I've been learning how to use AJAX with Drupal 7. I already know how to use the '#ajax' attribute with a form and also how to use the 'use-ajax' class with a link.
I have a nice jQuery slider on my ...
3
votes
3answers
4k views
Multiple Values to Trigger #states
How can I have multiple values trigger the Form API's #states?
Say for example, I wanted this field to be visible not only if the value is 5 (currently works below), but wanted to make the field ...
3
votes
2answers
366 views
Block/mosaic type homepage with heavily interactive menu
I wanted to know if this was possible to do for a Drupal website like this website has the main navigation how it works and interacts with the main content layout. http://goo.gl/HQ4P8H
What modules ...
3
votes
3answers
6k 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 ...
3
votes
1answer
7k views
How to get rid of added URLs when printing a Bootstrap-themed page?
When I print a page from my Bootstrap-themed site, all the links (and images with attached urls) have a printed representation of the link inserted into the printed page, right after the linked ...
3
votes
1answer
3k views
Best way for including javascript/jQuery OnLoad in EVERY page on my site
Currently, in my theme.info file I am including 2 scripts:
scripts[] = js/backstretch.js
scripts[] = js/scripts.js
Backstretch is a jQuery plugin that allows for an expanding background image to ...
3
votes
2answers
196 views
How do I make a Drupal 8 theme require Jquery (for anonymous users)?
I'm creating a theme for D8 called 'herchel'.I'm trying to get this theme to require jquery on all pages (D8 doesn't load Jquery for anonymous users by default)
Looking through the what little ...
3
votes
1answer
6k views
Adding a full screen background image to Drupal 7 / Bartik theme
Has anyone managed adding an image as background to a Drupal 7 with default Bartik theme?
Maybe using a fullscreenr plugin for jQuery?
I'm not sure where to store that code best and do I need to ...