JavaScript is a prototype-based object-oriented scripting language that is dynamic, weakly typed and has first-class functions.

learn more… | top users | synonyms

0
votes
3answers
24 views

How to add js file in only 1 node?

I made a custom js script for a little calculator. I want to use this in only 1 node (article or page) so I do not want to load it via tpl files etc because I do not need it sitewide. And also: if ...
0
votes
0answers
21 views

Infinite Scroll on Drupal 7 with AJAX

I am trying to create an Infinite Scroll system to display past events on a page. What I want is, when the top of the page is reached, I want to load past events. I created the following JQuery: ...
0
votes
0answers
16 views

Is it possible to detect files of a specific type in a specific directory using JavaScript? [on hold]

I am trying to create a JavaScript program embedded within HTML that detects the number of .htm and .html files in a specific file directory. Is there a possible way to achieve this?
-1
votes
0answers
20 views

Problem in manage display in content type [on hold]

I used semantic ui template but there is one problem, please help me;
0
votes
0answers
18 views

Calling a contact form in a certain page

I want to see my contact form in another page. I have now a link, www.xxx.com/index.php which is the contact form and dose work perfectly. I want to put it in another page let's say ...
0
votes
0answers
16 views

Can I get the node id on the client side from the Drupal JS object?

Can I get the node id on the client side from the Drupal JS object? I have a drop down of Organic Groups inside a form exposed through Advanced Form Block. I'm trying to default that select list to ...
0
votes
0answers
17 views

How do I reload block content and make sure all JS fires properly?

I have a block and I want to reload its content when some conditions are met via JS. Currently I do not have any libraries attached to it but I am wondering that, in case there are some javascript ...
-1
votes
1answer
40 views

How to make a field required using JavaScript injector

I have a field that is part of a content type that I need to make required by using a JavaScript injector. The reason that I can't just make it required while setting the rules for that field is ...
0
votes
1answer
33 views

Drupal.settings.basePath is not giving the base_url in js

When I alerted the Drupal.settings.basePath it's just giving me a /. I have a full $base_url in settings.php. which I'm expecting to see instead of /. How can I get the correct value of the base URL ...
1
vote
1answer
18 views

Is there a way to assign an html ID automatically to a field in a content type?

I am using JavaScript in my custom module and the field is inside an div, but that div only has a class tag. Is there a way to automatically give an ID to the field so that whenever it shows up, it's ...
0
votes
0answers
6 views

Leaflet appears as Grey Box and Zoom not working

I am using geofield and leaflet.widget in a content type field. I have a leaflet view containing nodes with these field locations. Upon displaying the view at first a grey box appears in place of the ...
1
vote
2answers
46 views

How to call view block on click?

I have a page/node that contains 15 view blocks, each view block has many fields and all of this causes the page to load really slow. How do I load the view block only when I need it? for example I ...
2
votes
0answers
28 views

How to tell if user selected an autocomplete option in a form?

I created a form that has an autocomplete field of registered users and it is attached to nodes. In the form validation function I check if the string of the textfield is a valid user but in order to ...
0
votes
0answers
13 views

How to use JS and browser's local storage to store ( on each page visit) the node' taxonomy term?

We are trying to create a way to write some JS to utilize a browser's local storage to store the node's taxonomy terms of all the Drupal pages a user visits. On top of that we want the JS code to be ...
2
votes
0answers
23 views

How to pass cookie value into Drupal View

We want to create some logic using JS that creates a cookie and set the node's taxonomy term id (preferred) or taxonomy term name as the cookie value. Then we want to use the cookie value to filter a ...
0
votes
1answer
23 views

Does anyone know solution for adding pure javascript filter for View?

As in queston. I was googling and searching forum, but found nothing useful. I want to setup dynamic filter for a view. Eg. ...
1
vote
3answers
48 views

Add javascript to a content type form in Drupal 7

I'm trying to add a custom javascript file to my article content type forms (add/edit). I've tried mythemename_preprocess_page, hook_form_alter and theme_content_type_node_form to no avail. They ...
0
votes
1answer
46 views

How to validate webform with JavaScript?

I've got a Webform for which I need additional calculations to hidden fields. I've added a JavaScript file to the page by using drupal_add_js. And let that be the only part that works... My ...
0
votes
0answers
11 views

How to define fallback libraries?

In case I use libraries from external sources, like getting jQuery from CDN instead of using the local file, how can I handle cases when the external file doesn't load? Does Drupal have a feature for ...
1
vote
1answer
12 views

Prevent loading certain script set in .info file in Drupal 6

I have a theme with several template files using <?php print $scripts ?> to load a list of scripts set in the theme's .info file. What's the best way in Drupal 6 to exclude one of the scripts ...
0
votes
2answers
35 views

Are absolute paths allowed in info files?

I'm writing a .info file for a module, and I want to include a script which has been installed in /sites/all/libraries: So I have included the line below in my .info file: scripts[] = ...
1
vote
2answers
89 views

What hook_form_alter code do I need to change an exposed filter from a text field to a select box search?

I have a view that has an age to and and from fields, and others also that I want TO and FROM. These are integer fields, so drop down select doesn't work, better exposed filters is also not an ...
1
vote
1answer
53 views

How do I enable a custom JS file in my Drupal site? [duplicate]

In my Drupal themes' folder I've created a file named "custom-js.js". I created this file to use 2 jQuery manipulations on a small text block that appears in all pages of the site. My question is, ...
2
votes
1answer
40 views

How to add javascript after form was validated with ajax callback?

I created a simple form. How could I add JavaScript commands after form was validated? Why is it so hard do this? $form['submit'] = array( '#type' => 'submit', '#value' => 'submit', ...
0
votes
0answers
23 views

End Date always after Start Date?

Related to, but not the same as Change end date automatically after changing start date I'm looking for a method to have Date fields do some sort of validation on the end date. I don't want it to get ...
0
votes
2answers
17 views

Can a javascript variable be made configurable?

I defined a variable in my .js file and want the user/client to change that as per his needs. Is it somehow possible to use that value in forms in drupal?
-1
votes
0answers
21 views

Passing Javascript variable in my module file [duplicate]

How can I pass a JS variable to my module file using ajax in drupal? var start; start = new Date().getMinutes(); window.onbeforeunload = function() { var end1 = new Date(); var end = ...
0
votes
1answer
36 views

How do I add a Javascript library to a field formatter?

I'm trying to include a Javascript gallery (jQuery lightGallery) on my new Drupal 8 site and wrote a field formatter for this purpose. Now I need to add the jQuery lightGallery to pages using this ...
0
votes
2answers
53 views

How to record what time user has spent on my node?

I want to record the time a user has spent on my particular node so I could show a pop up to the user to register once the user has read 3 article. But the user must have spent at least 30 seconds on ...
1
vote
1answer
43 views

Is there a way to check user permissions in javascript?

Is there a way to check user permissions in javascript? I have a segment of code that I only want visible if the user has the proper permissions, and I think it would be easiest way to check the ...
0
votes
1answer
18 views

Duplicate / Triplicate inline javascript

On some pages of my site when inline javascript has been added to page it get added multiple times. I've looked through my base theme (Zen) and my default theme (custom) for anything that may be ...
0
votes
1answer
28 views

Error on Insert Map

I am using Drupal 7 and the Google Map Field module. When I click on the Insert Map button, the Firebug console shows this: TypeError: $(...).prop is not a function It seems like I need ...
0
votes
2answers
40 views

How to do integrate javascript in drupal way

I want to integrate this Flex Slider code to drupal but without success. Please help. here is the code if($('#homeSlider').length > 0) { var hIndex = 0; var $hCap = ...
2
votes
1answer
25 views

Need help Converting a jQuery event to a Drupal Behavior

I have a Drupal 7 web site that is using jQuery animations to fadeIn div tags. I need an event to capture a fadeIn when it is completed. I have found a sample jQuery example that does what I need it ...
0
votes
0answers
8 views

Hooking into tableDrag onDrop event when using draggableviews

I am using draggable views module in one of my projects, and it works like a charm. ;-) I now want to "hook into" the onDrop event in one of my custom modules to add some logic there (altering an ...
0
votes
1answer
13 views

Can't open these tabs in my Browser

I'm working with my college on a drupal website. However, we're both logged in as Admin, but I can't open these tabs. He says he has no problem with it and told me it could be a Java problem. I ...
3
votes
2answers
71 views

Where should I store 3rd Party external js libraries?

This is a follow up to Define JavaScript library in Drupal 8 I have a third party library that I don't want to bundle with a module. In Drupal 7 I could just ask the user to extract to ...
1
vote
0answers
17 views

WYSIWYG TinyMCE add Custom Javascript

So I am running into the issue where I can't add any custom javascript to elements inside the WYSIWYG because its an iFrame. Is there some special way of adding custom javascript. The main thing I ...
0
votes
1answer
44 views

Create node from JSON

I'm looking to write the following module, any help, guidance, and advice would be greatly appreciated. User is logged into site. Site has two content types: page & note. Logged in user can ...
1
vote
0answers
32 views

Views display tabs remember last tab(need help with adding cookies or use $_session)

hey im using Views Display Tabs to display 2 pages of view and allow the user to switch between them however the last selected tab doesnt save and i want it to do that i have tried a few things that ...
0
votes
1answer
31 views

jQuery scripts not working on my Drupal theme

This script from JSFiddle that works: https://jsfiddle.net/ryXFt/704/ Does not work in my Drupal theme (yes, it does load, I can see it via Firebug). All I do is just wrap up the code to match Drupal ...
2
votes
2answers
52 views

Why does external js only appear in header? D7, in a block, via custom module

I'm trying to add a box.com file upload widget to certain pages in a block. The upload widget is an external js script. I'm adding it via a custom module, using hook_block_view, switch ($delta) { ...
2
votes
2answers
58 views

Webform live calculations in table/matrix

I am trying to create a work time allocation webform. My goal is to create a table (6 columns and addable rows) and get a live sum of all columns at the bottom. (edit: pardon my lacking terminology. ...
0
votes
0answers
16 views

Is it possible to insert php values into added javascript files in Drupal? [duplicate]

In Drupal javascript files can be added for example by drupal_add_js() function, or (in my case) attached by form API: $form['#attached']['js'] = array( drupal_get_path('module', 'activit') . ...
0
votes
0answers
16 views

How to use tabledrag within multiple tables

I have a form that has three groups of elements which are presented via tabledrag form element. I would like to be able to move the rows between the tables, so not just within a single table as ...
1
vote
2answers
86 views

How to animate set of titles of a View using JQuery

There is a View of latest news title linked to the node page and I need to display them like this Effect. I've trying to do it by creating a new template file for my views named: ...
2
votes
2answers
80 views

Why are the CSS files in my .info not applied (scripts work fine)?

I have a list of CSS files from a premade theme called artifical reason they are listed in my .info file as such stylesheets[all][] = assets/css/style.css stylesheets[all][] = assets/css/preload.css ...
0
votes
2answers
25 views

How to conditionally load javascript file on view page

I'm trying to load some theme javascript only to one view(multiple displays). I've tried to use the views preprocessor funciton, but maybe I'm doing it wrong: function ...
0
votes
2answers
35 views

Translate string in javascript

There is a string which gets displayed in the mobile menu. var arrowimages = { down: 'downarrowclass', right: 'rightarrowclass' }, $mainNav = $('#navigation'), $mainList = $mainNav.find('ul').eq(0), ...
0
votes
1answer
26 views

Add JavaScript to a page without access to core files?

I apologize in advance if this is a really simple question, but I'm pretty new to Drupal and still figuring out my way around things. So I was wondering if it is possible to add JS to a certain node ...