All Questions
Tagged with 7 javascript
995 questions
0
votes
1
answer
199
views
How can I add an external/third party library with type = 'module' using drupal_add_js()?
drupal_add_js('path_to_external_JS_file_on_CDN', [
'every_page' => TRUE,
'type' => 'external',
'defer' => 'defer',
'attributes' => [
'async' => true,
'type' =...
0
votes
1
answer
1k
views
Using SweetAlert with preventDefault()
I have an event on a form submit.
I set preventDefault() to stop the form submitting then pop SweetAlert with a confirmation callback. If they decide to go ahead, it POSTs the form to Drupal.
It doesn'...
0
votes
0
answers
45
views
Use javascript code in a specific div of the webform page
I have a website that was set up using Webforms with page breaks. So on the same URL, there are multiple "pages" and div blocks on each page, with a progress bar on top so you know what &...
42
votes
3
answers
50k
views
how to send variable from .php file to .js file?
I hope someone is able to help me.
The problem is the following one:
1)I have module in which a assign the variable in order to send to the template file php.tpl
<?php
...
$testvar="Hello from ...
29
votes
7
answers
54k
views
How to programmatically 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 ...
0
votes
1
answer
693
views
How to reference external JS callback in custom module
So I apologize if I mess the terms here up, I'm relatively new to using jQuery in Drupal. I'm trying to implement a custom Google Map application with the V3 API. When I started mocking the module up ...
1
vote
1
answer
731
views
Drupal EU Cookie Compliance module conflict with theme JQuery
When I first installed the module, it'd only appear in admin pages.
After some investigation, I discovered the cause was some sort of conflict with my themes jquery: jquery-1.11.2.min.js.
If I ...
25
votes
3
answers
15k
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 ...
59
votes
2
answers
46k
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', ...
20
votes
2
answers
24k
views
Add external javascripts
Is it possible to add external javascripts directly into the .info file of a theme?
e.g scripts[] = http://cdn.jquerytools.org/1.2.6/jquery.tools.min.js
35
votes
4
answers
19k
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 ...
31
votes
2
answers
36k
views
Eliminate render-blocking JavaScript and CSS in above-the-fold content
I am building a Drupal 7 site. These are some of the modules I use: Adaptivetheme (theme), Views and Content Panes, Panels, Mini panels, Panels everywhere, Page manager, Superfish for menus, Addthis, ...
1
vote
0
answers
981
views
Video does not pause automatically when slider change in FlexSlider
I'm using version drupal 7 to create the "slideshow" to display the slideshow of the video, each video is embedded in its own content item.
When the user starts to play the video, if the ...
0
votes
1
answer
537
views
How to add onBlur attribute to ZIP code field in Address Field
In order to control the input format in the ZIP code field in the dynamic address fields provided by the Address Field module (I use it in Drupal Commerce) I need to add the attributes onKeyUp and ...
2
votes
1
answer
1k
views
How do I properly attach Google Maps API?
So, I've posted on this elsewhere and I seem to either get half answers but they've gotten me closer to a solution but not over the finish line.
I'm trying to implement a custom Google Maps ...
2
votes
2
answers
7k
views
How to drupal_add_js an external and defer script
I've spent quite some time on drupal_add_js and didn't manage to solve this. How can I load an external JavaScript script which will also have the defer attribute?
I want to use this type of syntax:
...
24
votes
6
answers
21k
views
Using built in jQuery UI in my theme
Every page of my theme will need to use jquery UI. I know it's included with Drupal 7, but I can't really decipher Drupal's way-too-technical documentation. It looks like the only way to do it is ...
17
votes
5
answers
34k
views
Add JavaScript at the bottom of a page
How can I add JavaScript scripts to bottom of a page, in my template?
0
votes
1
answer
1k
views
Include Lead Forensics code in all pages
I'm trying to include the tracking code Lead Forensics gave me. The code is:
<script type="text/javascript" src="http://www.path-trail.com/js/11111.js"></script>
<noscript><img ...
1
vote
1
answer
731
views
How to call custom javascript function defined in js file from .module file
I have some custom menu defined for which in the page callback function I want to execute some javascript function defined in some js file which is included in .info file.
The alert and console.log ...
0
votes
2
answers
1k
views
How to use drupal_add_library with a module?
I'm new to Drupal and don't really understand how to set up drupal_add_library.
I've made a simple module that links out to a .js file. However, this .js file depends on a couple of generic functions....
0
votes
1
answer
626
views
Using 'return' with an ajax callback renders an entire page before my content is loaded
I'm developing a module that uses Openlayers maps and Drupal Commerce. When you click on the map, you should see products that relate to those coordinates of where you click. I have this working ...
-3
votes
1
answer
168
views
How to track recently viewed nodes using JavaScript on a completely cached website?
I want to make a block of recently viewed nodes on a website which is completely cached using Boost module (it saves a static HTML page for every request on the website). I don't want to disable Boost ...
0
votes
4
answers
3k
views
How to run jquery codes before and after ajax call?
I want to create a loading code while the ajax call is not yet complete, AND enable my jquery code after calling the ajax of drupal form. The ajax I'm referring to is the "Add new field/Add more" of ...
6
votes
1
answer
1k
views
How to add multiple products to cart at the same time with attributes
I have different view blocks that display multiple products on the same page, each product has their own attributes such as product bundle and custom line item, these serves as an option set / ...
0
votes
1
answer
483
views
check if a page has been redirected and then add a class to a certain div
Im using the redirect module to redirect /page/scheduling to /page.
I need to check if the user arrived to a certain page by this redirect.
by checking this i will then add a class to a certain div.
...
1
vote
7
answers
1k
views
How to remove default 'search' text form search form
I can't seem to figure out how to get rid of the default text "search" on my search form (located here: http://dev.mysourcewise.com/media-center)
I can confirm the following works in Chrome's console:...
2
votes
5
answers
21k
views
How to add Javascript tag in the head tag?
I want to add Javascript in Head Tag. I found an answer in
How to add script to <head>? but it doesn't work for a theme.
function mytheme_preprocess_page(&$vars, $hook) {
...
0
votes
2
answers
650
views
How to attach external js to Drupal.behaviours
If we write js code in Drupal.behaviours like below
(function($) {
Drupal.behaviors.my_module = {
attach : function(context, settings) {
}
};
})(jQuery);
that code will be execute multiple ...
3
votes
1
answer
4k
views
Is jQuery .once() needed if we filter by context?
When implementing a Drupal behavior, a selector can use the 'context' parameter to let the behavior only apply to new elements. On page load the context is the document (I think), on ajax load it is ...
1
vote
1
answer
2k
views
How do I display, in a ColorBox popup, a caption AND a title (caption from image 'alt' attribute and title from 'title' attribute
I am trying to display in a ColorBox popup, a caption AND a title (caption from image 'alt' attribute and title from image 'title' attribute).
The colorbox is opened when an image is clicked.
Here ...
0
votes
1
answer
103
views
Validation doesn't show an error when the value entered in the field doesn't respect the minimum length
I am using the Field validation module to validate a text field using the Length rule with a minimum length of 1.
When the field is left empty, no validation error is shown.
Setting the field as ...
0
votes
1
answer
2k
views
$.cookie is not a function from form.js with block cache
I am getting this error if I turn my block caches on.
I have traced back the origin back to Drupal core form.js but can't seem to see what's going on here.
Any ideas?
Here is the debug:
form.js?v=7....
12
votes
3
answers
18k
views
How to trigger Drupal.attachBehaviors after successful Ajax
I have a module that updates a node via ajax when a link is clicked.
The link is a toggle, it should update the node with value 1 on first click, then with value 0 on a subsequent click, etc. Like ...
2
votes
2
answers
5k
views
How to call external api to pull data into json format?
There is an api that is used to expose data from an external website. How can I use the drupal API to call the external api and pull the data into json format?
the external api would be, for example, ...
10
votes
4
answers
13k
views
How to get the node ID in jQuery/JavaScript
Is there a definitive, universal way to do this? For example using some environment variable that comes with Drupal.behaviours?
I have done some research and there seems to be no common answer.
2
votes
4
answers
10k
views
How do I add a custom script on a specific page?
I wanted to add custom JavaScript code on certain nodes.
I have written this code in the html.tpl.php template, but this doesn't work. (donate is the path alias for a node.)
<?php if(arg(0) == '...
3
votes
3
answers
1k
views
Add JavaScript to a node form
I'm trying to add a custom JavaScript file to the forms to create or edit a node.
I've tried mythemename_preprocess_page(), hook_form_alter() and theme_content_type_node_form(). They seem to pick up ...
0
votes
1
answer
524
views
Confirmation pop up on login submit
I have built a site using drupal 7.41. I have added the login form by adding this line in my page.tpl.php "print render($page['login_container']);".
When user click on the login button I want to show ...
0
votes
1
answer
1k
views
Fullcalendar is putting my events into the "all-day" category
I'm doing some stuff with fullcalendar and views that, more or less, is working. In particular, a month view properly shows a set of events on the day in which they're scheduled. However, when I ...
1
vote
2
answers
914
views
Add conditional javascript from CDN (external library)
I know it has been discussed here several times, but:
Is there a way to include conditional JS from CDN in the head section?
My goal is to somehow use drupal_add_js, external. That will stick in the ...
1
vote
3
answers
4k
views
How do I include a script in a node body?
I am trying to include JavaScript code in a node body, when I am editing the node.
The purpose of that code is hiding a <div> tag whose ID is test.
The code was added to the node, but the <...
1
vote
2
answers
2k
views
How to add validation on 'next' button using fieldgroup module
I am creating a multiple page registration form using the field group module and
I want to add validation on 'next' and 'previous' buttons.
If the first page's field is empty, the user can not go ...
7
votes
7
answers
21k
views
How can I trigger a javascript function when a Drupal ajax call is complete?
I need to do some extra things after Drupal ajax is done inserting some stuff into the DOM. With jQuery this was brain-dead simple, but I can't for the life of me figure out how to do it in Drupal 7 :...
0
votes
1
answer
903
views
Conflict between ajax callback and jQuery UI dialog
I have a button that triggers an AJAX callback with the form api like so :
$form['show_modal'] = array(
'#type' => 'submit',
'#value' => t('Some crazy text'),
'#ajax' => array(
'...
12
votes
2
answers
7k
views
Right way to add JS and CSS to node/edit and other forms
I am making a site with a lots of JS, and I am wondering where I should put the JS code. Optimally I would like to keep the JS with each module and not the theme layer. Some content could be exposed ...
2
votes
2
answers
1k
views
How to validate file is selected or not on ajax processed jquery validation
I am trying to do jquery validation on file upload for file is select or not. I want when user click on upload before submit check file is selected or not. if not stop ajax request. Any Idea to ...
4
votes
2
answers
3k
views
How can I create an image gallery?
Currently I am running in D7 with the following modules:
Media 7.x-2.0
Views 7.x-3.7
Colorbox 7.x-2.4
I am trying to create an image gallery using these modules with the following steps. Please ...
1
vote
2
answers
4k
views
Remove All Unwanted js and css files from theme
I create a website based on Drupal. When I look at the JavaScript and CSS files loaded from Drupal, I see many unwanted files loaded. I want to force Drupal to load only those files added to the .info ...
0
votes
1
answer
938
views
ajax update block on click to link
I am using jQuery Ajax Load module in my site to load some contents from url to show on specific div which has a required class. With this module I am able to fetch the Page content from URL through ...