Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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' =...
monster_energy's user avatar
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 &...
Rachel C's user avatar
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. ...
João Mateus's user avatar
-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 ...
NSp's user avatar
  • 1
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 ...
user3108268's user avatar
0 votes
1 answer
99 views

Inline Javascript throws an error on drupal_add_js() within an AJAX callback

I am trying to get JavaScript to measure a text field and auto submit at a character limit for an Ajax callback to be validated against a Luhn Algorithm and errors out on failure to validate. I found ...
wilburunion's user avatar
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 ...
evasim's user avatar
  • 11
0 votes
0 answers
150 views

Add external script in head after CSS loading

My question maybe is a little bit strange. I have Drupal 7.x and i need to add in <head> a script to verify my adsense account: <script data-ad-client="ca-pub-xxxxxxxxxxxxx" async ...
user3162975's user avatar
0 votes
1 answer
180 views

What is the recommended jQuery and jQuery UI version?

What is the recommended version of jQuery and jQuery UI that I should use on a Drupal 7.77 site? I know the latest jQuery version is now 3.5.1, but what is the recommended version for a Drupal 7.77 ...
Zeeshan Arif's user avatar
0 votes
0 answers
46 views

Checkbox Form Element: Displaying checkboxes value based on on/off

I have a checkbox form element that uses taxonomy terms via variable_get as #default_value; storing the result. I don't want to overwrite value, I just want the form to render/display checked ...
kubak's user avatar
  • 1
0 votes
1 answer
28 views

Javascript in Drupal

I was following this post on drupal.org - https://www.drupal.org/node/3075055 But I'm not getting the same result. I'm not experienced at all in javascript so maybe I'm missing something. Do I need to ...
zephirus's user avatar
  • 377
0 votes
1 answer
409 views

How can I change the 'type' of Drupal script tags from text/javascript to text/plain?

I could use some assistance in figuring out a way to change script tags for a Drupal 7 site to be "text/plain" instead of "text/javascript" And additional attribute(s). I can tell already that ...
Michael Bopp's user avatar
0 votes
1 answer
135 views

In node add, how to upload file using image from clipboard

How can I paste image from clipboard and save into image_field ?
DanielRatk's user avatar
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 ...
roger123's user avatar
0 votes
1 answer
559 views

How to load a internal page content within div? [closed]

I have following code in a basic page on drupal 7 <h2 id="tabs">Test Title</h2> <!-- Nav tabs --> <ul class="nav nav-tabs"> <li class="active"><a href="content/test" ...
Tapash's user avatar
  • 157
0 votes
1 answer
1k views

How to log to console when in a Drupal attach behavior?

I'm using Drupal 7. I have the following code that tries to log to the console: function mymodule_get_jquery() { $jquery = <<<JAVASCRIPT console.log("here"); (function($) { ...
MrSnrub's user avatar
  • 285
1 vote
1 answer
604 views

Node content is not shown

I installed DrupalGap. Everything works fine so far, except that the node body is not displayed. I have none of the mentioned interfering modules installed. I also tried with a fresh Drupal 7 ...
xandi's user avatar
  • 13
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'...
Andy's user avatar
  • 101
0 votes
0 answers
478 views

Get field value in viewer.js file (from pdf.js)

I created PDF files protected with password. They are uploaded to Drupal and the password is saved in a field pdf_password in Drupal. I would like the PDF to open them with pdf.js without having to ...
user1619177's user avatar
1 vote
1 answer
689 views

Add custom attribute to an external JS script

It's not really clear how to add custom attributes when adding an external JS script to the page. Currently I have this code: drupal_add_js('https://code.jquery.com/jquery-3.4.1.js', array('type' =&...
user avatar
1 vote
1 answer
2k views

How can I call custom javascript on successful webform submissions through hook_form_alter?

I have some custom js code which should be executed after successful webform's submission. JS Code : jQuery('document').ready(function(){ form_submit_telium(); }); below approaches, I already ...
Harshit Thakore's user avatar
0 votes
0 answers
79 views

Leaflet version not detected

I have a drupal 7 site, competely upd to date. Installed Leaflet en put the leaflet libarie (unzipped) (https://leafletjs.com/) (1.5.1) in the sites/all/libraries/leaflet. However, in the ...
Pieter-Jan Derks's user avatar
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 ...
donquixote's user avatar
  • 3,662
0 votes
0 answers
20 views

Hook to call a function after menu rebuild?

After a menu rebuild, such as one that occurs automatically when visiting the Modules admin page, some of my Drupal JS behaviors are not in the correct state. I need to re-initialize or attach them ...
mbomb007's user avatar
  • 536
-1 votes
1 answer
459 views

Why is the jquery_update module not supporting the latest jQuery version? [closed]

The recommended jquery_update module only supports 1.10. Why recent jQuery security version 3.4.1 not updated? https://jquery.com/download/ So is it recommended to make my Drupal site to update with ...
Navaneeth's user avatar
  • 172
0 votes
1 answer
36 views

How do I create a log/statistics of on page events?

I am using drupal 7, I have seen there are already statistic modules but can't find any for my situation On my website I am trying to track certain on page activities which site admins can see in a ...
Tasha Jordan's user avatar
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 ...
nizz0k's user avatar
  • 1,182
0 votes
1 answer
212 views

How do I include an affiliate script?

I am trying to add an affiliate script to my Drupal 7 website. I am doing this in a custom block. Specifically, I create a block, select the scripts text format in my WYSIWYG Editor, add the script ...
sp_key's user avatar
  • 1
0 votes
0 answers
356 views

drupal_add_js is adding .js file to footer despite me adding 'scope' => 'header'

I want to add an external file to the header. To that affect I copied what others have done and used drupal_add_js();: drupal_add_js('somefile.js', [ 'type' => 'external', 'scope' => '...
MeltingDog's user avatar
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 ...
nizz0k's user avatar
  • 1,182
1 vote
1 answer
203 views

How to add google maps js without breaking jquery?

So, I'm trying to implement a custom map using the Google Maps API in addition to a Google Map view. I'm working with an up-to-date D7 install. The reason for this is that I need to have multiple ...
nizz0k's user avatar
  • 1,182
0 votes
1 answer
2k views

How do I enable an onclick event in a link on a form?

I am using the following code. $form['test'] = array( '#type' => 'link', '#href' => "javascript:;", '#title' => t('Show'), '#attributes' => array( ...
helpdoc's user avatar
  • 73
0 votes
2 answers
242 views

How to add javascript with #attached in a node which contains a specific paragraph bundle

I need to attach js in all nodes with a specif paragraph bundle. I know how to do this with drupal_add_js, but I prefer don't use it to prevent cache problems. I am trying with hook preprocess_entity ...
SilviaGDLR's user avatar
0 votes
1 answer
509 views

Using JCF with dynamic forms

I want to use Javascript Custom Forms (JCF) to get more attractive and consistent looking forms on my Drupal 7 site. I've got it working to a degree, however when the form changes with AJAX, the new ...
spiderplant0's user avatar
2 votes
1 answer
67 views

Override one line in core tabelselect jQuery behavior so custom checkboxes aren't affected

I have created a custom table using a Form API tableselect element, and within my table, I have embedded a checkbox form element that is checked based on an entity field (see here for details). The ...
wonder95's user avatar
  • 1,219
1 vote
1 answer
32 views

Views switches to another view on apply or any change

When I'm working on a block display in Views on Drupal 7, and hit the "Apply" button, I'm taken to the master (or first view), instead of staying on the block display that I'm working on. How do I ...
user90577's user avatar
0 votes
1 answer
220 views

How can I toggle required field?

Using Drupal 7. I'm trying to toggle required field based on the click of a radio button. I already tried the proposed solution in this post but it did not work. Here is my code: $(context)...
lane's user avatar
  • 473
1 vote
1 answer
249 views

Show and require field if birthday (date field) is less than 18 years old

I have a field that should be visible and required if the user selects a date that would make them less than 18 years old. If they are over 18, the field should be hidden and not required. Right now, ...
MrPeanut's user avatar
  • 383
1 vote
1 answer
730 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 ...
solaris's user avatar
  • 51
-1 votes
1 answer
36 views

Unable to pass the value from .module file to JS using the implementation given below

.module file function taxonomy_fancybox_menu(){ $items['fetch-popup-markup-data/%'] = array( 'title' => 'Store markup', 'page callback' => 'ajax_fetch_markup_popup_data', 'page ...
harshal's user avatar
  • 4,354
0 votes
1 answer
30 views

Add JavaScript and css to page with nodes only if there is no tag in any of the nodes

I wrote a module that adds javascript and css to a page with nodes of type 'rower', now I need to add javascript and css to the page only if there is no tag with id == 1503 in any of the nodes. I ...
Iurii Prytula's user avatar
-1 votes
1 answer
268 views

Custom Jquery for Entity reference form

How do I add Custom Jquery On-click event on a checkbox which is inside an Entity reference form? In the below screenshot, "Study" is the Parent node. "Demographics", "Biological collections", etc. ...
shablm's user avatar
  • 99
3 votes
2 answers
372 views

Cannot update checkbox with services

I have been trying several configurations for trying to update a user account checkbox to uncheck it, with no success. I have been able to check it without issue. updateCharType = function (token) { ...
Jack Ryan's user avatar
  • 2,307
-1 votes
1 answer
56 views

js in default/files causes extreme slowdown of website [closed]

for the past week my website is plagued with over 4000ms hanging upon entering, more so at sometimes. After using firefox's performance monitor, I pinpointed it to several lines of code in a js file ...
A.Lopez's user avatar
1 vote
1 answer
174 views

How to add multiple js files in hook_field_widget_form()?

When I load two JS files using drupal_add_js() as can be seen in the code marked "After", it does not show alert() text on page load and also when I click on the button created in the form to load ...
harshal's user avatar
  • 4,354
0 votes
1 answer
682 views

Where do I insert code into the header?

I recently updated my Drupal 'Newsflash' theme but one of my javascripts stopped working. I contacted the writer of the js script and he suggested that my head section has lost the markup for ...
user avatar
1 vote
2 answers
2k views

Scroll to search results on Views Exposed Filter submit button

Hi I've made an 'Advanced Search' using Views + Display Suite in Drupal 7. https://www.oldertenants.org.au/research-library-advanced-search There's too many search filters so the default behavior of ...
Ruben's user avatar
  • 13
0 votes
1 answer
288 views

correct way to load JS library for custom module

I am trying to use d3.js in my module, but I am facing some issues. I have the D3 module installed in sites/all/modules/d3/ and d3.min.js installed in sites/all/libraries/d3/, and I can see the d3/...
user299791's user avatar
0 votes
1 answer
58 views

Fancy insert stopped working

Does anyone have an issue with the fancy insert module, not actually inserting the image on click recently? It looks like the javascript in the fancy insert was hooking into the insert button by ...
Roland Snowe's user avatar
0 votes
1 answer
445 views

Keep getting "Bad request" messages in browser after adding JS

I have added this script in my Drupal 7 site to make the site remember the last clicked Quicktab and then open that tab on page reload: // JavaScript Document (function($) { Drupal.behaviors....
TBJ's user avatar
  • 616

1
2 3 4 5
20