Skip to main content

Questions tagged [javascript]

Use for questions about JavaScript code that is very specific to Drupal.

Filter by
Sorted by
Tagged with
1 vote
1 answer
1k views

Override module javascript file in theme or custom module

Is it possible to override a single javascript file from a module within a theme or custom module? My specific use would be for Views/js/ajax_view.js - I've had to apply multiple patches to get ajax ...
1 vote
1 answer
502 views

Qiuck tabs shifts the Openlayers map background layer

Im displaying the list of locations (address and map Openlayers + Geofield) using views. There is no problems when displaying view in ordinary way, but when the view is displayed inside quicktabs the ...
1 vote
1 answer
2k views

jQuery dialog is duplicated when set on a form that uses AJAX

Im using jQuery dialog on my form. Drupal.behaviors.custom = { attach: function (context, settings) { $('.form-container').once('form-cont', function () { Drupal.custom.modalLinks(); })...
1 vote
1 answer
3k 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' ...
-4 votes
1 answer
54 views

Add Javascript to a specific 'Basic page' or node based on its title

In a Drupal 10 site I have a page (content type: Basic page) that needs a small Javascript fragment defined in a Javascript file that was added as an asset to the theme.libraries.yml file. I don't ...
0 votes
1 answer
617 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
3k views

Why does jQuery slideToggle revert back to initial hidden state after running?

I have a Superfish menu and a simple jquery slideToggle animation attached to each menu item. I am using Drupal 7 & the Superfish module. The idea is that on click it will show the body content ...
1 vote
1 answer
707 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 ...
1 vote
3 answers
574 views

Why isn't Drupal's core once() function working in my simple test script?

I am trying to console.log a message once and only once in Drupal 10. I am cutting and pasting examples from https://www.drupal.org/node/3158256 into my file and I am still seeing the message appear ...
0 votes
2 answers
2k views

Attach a jQuery function to an AJAX response

I'm trying to attach a jQuery function to an AJAX response. The JavaScript file content is the following. (function($) { $(document).ready(function(){ $('.rembourcement').find( ".button" )....
0 votes
1 answer
2k views

Node Gallery Lightbox

I am using Node Gallery Module, just want to know if there is a way we can open the images in Lightbox or Colorbox? I know this can be done in Media Gallery module but can not find any way in Node ...
0 votes
1 answer
749 views

Submission of dynamically generated input fields

I have created data entry form using Drupal 8 Webform (Yaml forms), Part of the form is table field which hosts dynamically generted textfields using jquery shown below: $(document).ready(function(){...
0 votes
1 answer
2k views

Multiple checkboxes in an AJAX calls

I've been developing this phonegap app and I'm stuck with a few things and one of them is multiple checkboxes - I hope you can help. I've got the below code HTML <input type="date" id="date" /&...
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....
3 votes
3 answers
1k views

Views UI doesn't provide links to expand fieldsets anymore

I have moved an entire drupal site to another server. While everything else seems to work fine, I can't quite access collapsed fieldsets in Views UI anymore. It looks like this All fieldsets (STYLE ...
0 votes
1 answer
912 views

Form validate without submit action

I'm developing a site that it will use Services for the CRUD operations and ANGULARJS for the comunication frontend <-> backend. Now when I want to insert a new content of content type FOO I will ...
0 votes
3 answers
2k views

Google API callback doesn't work

I've created this javascript (delivery.js) that is supposed to take a pre-existing div on a webform page and append a Google Map to it, along with a few circles of differing radius. Here is my ...
0 votes
1 answer
926 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 ...
0 votes
2 answers
628 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 ...
7 votes
3 answers
10k views

#states visible

The states visible seems to work correct in D7. In D8 I want to test make a field visable if one OR another field have a value. And also when two fields have a value. What I have below works if both ...
0 votes
3 answers
3k views

Show node field as a carousel using jCarousel module programmatically?

I have a content type with a fiel called: fotos-carousel (image type) which I want to show as a carousel. I can't use views to do this. I installed the jcarousel module and read the documentation to ...
2 votes
2 answers
2k views

Trigger jQuery "add more" multiple times

I have a form that I am filling with default values in hook_form_alter. Some of the fields are in a in a field group and I need to trigger the "add more" button using code. I figured out how to send ...
0 votes
1 answer
584 views

Flexslider carousel using template.php

Views with flexslider takes lot of times in rendering items/images. Situation is that I have more than 5 flexslider carousels on the front page. So I changed to go without view with flexslider. I am ...
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
2 votes
1 answer
478 views

Add inline widget to product display

I am trying to integrate our Drupal 7 Commerce install with Digital River's where-to-buy widget. All I need to do is add a little JS to the product page, with a script variable set to the product sku....
1 vote
2 answers
2k views

add link in Colorbox caption

In my gallery, what i write as image title is the caption of my image and that is great. Now I would like to add a link (external url) to my caption, how can i do that? I already try to write normal ...
0 votes
2 answers
481 views

How do I add a basic FlexSlider to the body?

I only need a very simple slider on a single page and so I just want to use Flexslider's most basic HTML options. But I cannot get it to work! My code is pasted from http://flexslider.woothemes.com/...
0 votes
2 answers
1k views

Display images of a specific content type in a lightbox when vocabulary is clicked

Background I am using Drupal 7 and I have a taxonomy "Kitchen Type" and content type "Kitchen Picture" having default field_image for images. There are three Kitchen Types Traditional, Contemporary ...
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 ...
1 vote
3 answers
1k views

How to dynamically pass a user field value to jQuery?

I have a notification bar with a counter, it actually prints the user's "notifications" field value (if it's greater than 0): <div id=container> <a href="#" class="activity_link">Activity&...
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
533 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 ...
0 votes
1 answer
885 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( '...
4 votes
2 answers
4k views

How to trigger a form and pass variables to $form_state with jQuery?

What is the way to trigger a Drupal form via JavaScript, and pass new values to $form_state while doing so? I have a main form, which has an element that triggers a jQuery UI dialog with a form in it. ...
2 votes
1 answer
1k views

Add query parameter from url to all links on the page

How to Add query parameter from url to all links on the page? Basically I want to get the Query parameter from url and then attach that on all the links on the page. JQuery or PHP, Any solutions? ...
-3 votes
0 answers
30 views

get the facet taxonomy label from the query using JS

i have set a facet using a taxonomy ref field from an indexed search api view. Using JS: const searchParams = new URLSearchParams(window.location.search); const facetSearch = searchParams.get('f[0]'); ...
1 vote
1 answer
4k views

How to display google map field in hidden div?

I have a Google Map Field in my form. I'm editing the theme of the form and I'm using a jquery but the map is broken. The map is inside a div and the code of the template is this: And here is the ...
0 votes
2 answers
3k views

Fetching(GET) image url with applied image styles using jsonapi module

Looking to make request using the jsonapi module to GET all urls that point to the images optimized version of the image. If I use the Drupal front-end with Twig and view my page and inspect the ...
0 votes
3 answers
1k views

Dynamically changing the href on a link with data-dialog-type = modal does not work

For reference I am working on this issue for the Focal Point module... I have a link whose href is updated dynamically using js based on a particular user interaction (moving the focal point on an ...
1 vote
1 answer
522 views

#states on exposed filter form

I have a #states on the exposed filter form as follow: If field_a == 'b' then field_b show, field_c hidden; else if field_a == 'c' then field_c show, field_b hidden; All fields here are Select ...
0 votes
1 answer
2k views

Using #states to disable a field collection field

I am trying to disable a date field's second value, inside a field collection, but it isn't working. My hook_form_alter has this: $form['field_certification']['und'][0]['field_validity']['und'][0][...
1 vote
1 answer
436 views

trigger colorbox on view page load

What if I just want to trigger the first colorbox on a view page? maybe with js injector module. Drupal.behaviors.commerce_kickstart_theme_custom_mytest = { attach: function(context, settings) { ...
0 votes
1 answer
399 views

Long Ajax error using Date module Views and Fullcalendar

I have searched for many posts and i am already doing the suggestions. Nothing is fixing this. Fullcalendar module says to use the "use ajax" option within views but it throws a huge error. ...
0 votes
1 answer
687 views

How to show the webform submission page as pop up?

I have created the webform with two fields. When I submit the webform, its redirecting to the submission page. Now, I want to display the webform submission page as pop up. Thank you message and the ...
2 votes
1 answer
857 views

Custom Submit Callback only triggering when Form is Valid when in Dialog

I'm trying to create a node in a dialog with the following link: Enter the title of a registration form or <a class="use-ajax" data-dialog-options="{&quot;width&quot;:...
1 vote
1 answer
528 views

How to load jQuery UI after bootstrap js files?

I'm a newbie to drupal 7, And I'm facing a conflict between jquery.ui.button.js and bootstrap/button.js because jquery ui is loaded before bootstrap. How can I change the order and load jquery ui last?...
0 votes
1 answer
2k views

How to add jQuery Datepicker option which accepts a function as an argument

I have added a date_popup field to a form : $form['arrival_date'] = [ '#type' => 'date_popup', '#title' => t('Arrival date'), '#date_format' => 'd/...
4 votes
2 answers
2k views

Adding new rows on a draggable table via jquery

I have a draggable table with preloaded "new items" - sorta like the Power Edit feature of the menu_editor module. Everything works perfect. However, I want to have a button that adds a new row via ...
0 votes
1 answer
685 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 ...
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 / ...

1
2 3 4 5
65