This tag refers to the Drupal JavaScript system used for managing events on content.

learn more… | top users | synonyms

0
votes
1answer
17 views

Access Functions Attach in Drupal Behaviors From Global Scope

I have this Drupal Behaviors Javascript code: Drupal.behaviors.myid_templates = { attach: function(context, settings){ function local_function(){ alert('local_function'); ...
0
votes
2answers
16 views

Context in Drupal.attachBehaviors is object or string

What do we really pass to Drupal.attachBehaviors in context, is it object or string ?
0
votes
1answer
36 views

How do I clear settings from the Drupal object?

I have a module, which renders an AJAX form, which passes data to a script via drupal_add_js and stores it in the settings property of the Drupal object. My problem is that I cannot seem to remove old ...
0
votes
0answers
4 views

control what ajax action triggers reloading script

I am using Drupal.behaviors.myModuleBehavior = function (context) To wrap my script in order to load again on ajax opened modal window. However, there are various other ajax requests which trigger ...
1
vote
1answer
90 views

Drupal.behaviors function can't detect Views object when user is Anonymous

Goals: 1. have a button in a View that refreshes that View via AJAX on click event. 2. Load refresh script only on pages that have View named "my_view". I was able to achieve both of the following ...
2
votes
1answer
39 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
25 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
81 views

Not able to overwrite old value in Drupal.settings

I am facing Problems in overwriting old value in Drupal.setting. Problem Statement I am passing FID value from PHP to JS. At first it is getting correct value in JS. Ex. When PHP is passing FID=59 ...
1
vote
0answers
158 views

How to access actual JS settings of my module after ajax call?

I need to add some additional JS data for my views page. I write in my module: function mymodule_views_pre_render(&$view) { if ($view->name == "myview") { ...
1
vote
0answers
212 views

Drupal Behaviours - Call specific JS function from PHP

I have a google map module – it calls google_map.js to do the JSON parsing and create icons on a map The module calls the JS and passes the PHP variables across on this line – storing the array in ...
1
vote
0answers
21 views

jQuery behaviors [duplicate]

I'm designing my first drupal theme and I'm not very well experienced in this kind of stuffs. I tried to add some jQuery to my design so I saved this code into a .js file and add it to my theme.info ...
0
votes
1answer
121 views

Detaching Drupal Behaviors of another module

I'm using this module External Link module which adds "ext" as a class to any anchor tag matching the regex defined via the admin UI provided by the module. I then bind a click event to trigger ...
0
votes
1answer
249 views

jquery slide toggle - affects all on the page

I have a view with a list of a content type and using drupal behaviors and jquery toggle, I trying to toggle some content when the user clicks a div. The only problem is that it's affecting all the ...
0
votes
1answer
247 views

Adding imagesloaded to packery module

With many responsive designs it is not possible to assign image dimensions as they will be determined by the view-port dimensions. However some scripts, such as Packery, require image dimensions to be ...
0
votes
0answers
86 views

JS file (drupal.behaviors) that does some simple jQuery works for anon users but not authenticated?

I have an issue where a JS file I've included with my theme using the .info file works for anonymous users but not authenticated. It has a unique namespace and using the debugger, the contents of the ...
0
votes
1answer
300 views

Dont Refresh Drupal's Page after a button is click in Forms API

I had started developing a module in Drupal. I made two form controls: a fieldset and a button. The button calls a javascript function "myphoto_options" when it is click. This function only does an ...
1
vote
0answers
308 views

JavaScript behaviours don't run on first page load after clearing cache

Refresh the page again, however, and all behaviours function as they should. Why? (function ($) { console.log('This console.log runs'); Drupal.behaviors.endlessUniform = { attach: function ...
1
vote
0answers
39 views

Theme: one or multiple behaviors? [closed]

I'm looking for a standard approach to attaching behaviors in the theme. Usually I add a behavior per component e.g. search form, mobile menu, etc. With CORE modules, there is usually just the one ...
0
votes
1answer
66 views

Javascript closures in modules [closed]

I am trying to adapt some code I have written in javascript outside Drupal to a Drupal module: (function($) { Drupal.behaviors.myModule = { ...
1
vote
0answers
186 views

Drupal behaviors has conflict with .load() jQuery method

I am using drupal behavior i need to reload a menu after any ajax request. i have a jQuery function to reload the menu by .load() method. menu items reload properly after any request. but when i ...
1
vote
2answers
2k views

Can jquery code be triggered by ajax success?

I know that I can add any code inside ajax success like this $.ajax({ type: 'GET', url: element.href, dataType: 'json', success: function (data) { //mycode And ...
0
votes
1answer
140 views

Drupal.behaviours: how do I pass local settings?

The documentation on Drupal.behaviours suggests that local settings can be passed to Drupal's JavaScript behaviors. Rather than hard coding my series data into my function: series: [{ name: ...
4
votes
2answers
260 views

Why do I need to use .live() in Drupal Behaviors?

I am trying to be a good boy and use Drupal Behaviors to manage my JavaScript. My understanding is that one of the advantages of using Behaviors is that it frees you from having to use .live() to bind ...
0
votes
1answer
419 views

Open Menu links in new browser window

I have created various menus, via the menu structure->menu page in Drupal for various pages in my site. I want to have some, if not all, of these menu links to open in a new page. You can not add ...
0
votes
1answer
145 views

How to make sure my behavior is triggered before AJAX?

I have a form elements that looks like this: $form['properties'][$property->idProperty] = array( '#title' => $property->Label, '#ajax' => array( 'callback' => ...
0
votes
1answer
2k views

Jquery.on method returns undefined is not a function

My goal was to create a simple button which once clicked would hide/show a navigational menu, and change the footer's padding alternatively, I'd have used toggle if not for the latter condition. ...
2
votes
1answer
2k views

How do I get a data value after all AJAX calls are complete?

I'm modifying the content of the modal window that pops up when using Linkit module in a WYSIWYG. This modal uses AJAX so I have to use Drupal.behaviors for the first time. My code is structured ...
1
vote
2answers
987 views

Form API ajax calls reload attached JS using behaviors

I have leaflet map attached to my form, this is the container div I used: $form['general']['map'] = array( '#markup' => '<div class="map-wrapper" id="ngmap"></div>', ); Everything ...
0
votes
2answers
151 views

Drupal behaviors with non-core jquery

For various reasons I am currently working on a module with a version of jQuery and jQuery UI that is not core. In other words, scripts[]=js/jquery.js scripts[]=js/jquery-ui.js are declared in the ...
1
vote
0answers
112 views

jQuery UI tabs in behaviors.js

I want to use my theme's behaviors.js (not template.php etc) to create jQuery UI tabs. Here is an example of jQuery UI tabs where the js is $("#tabs").tabs(); My html = <div id="tabs"> ...
0
votes
1answer
564 views

Google map in jQuery UI tabs / Drupal behaviors.js

As you can see here the google map in the first jQuery ui tab loads correctly but the same map in second / third etc tabs does not load properly or loads off centre. As mentioned here the problem is ...
6
votes
2answers
2k views

Delay ajax call on textfield to allow for typing

I would like to delay ajax from firing in the same way that the autocomplete seems to work. For example, if a user it typing, the ajax will not run until 500ms has elapsed since the last keyup. I am ...
0
votes
0answers
97 views

How and where does drupal call Drupal.behaviors.password attach method?

I am experiencing a bug in my setup. The symptom is, that the translate variable in Drupal.behaviors.password in core module user/user.js populated from the passed in settings (settings.password) is ...
0
votes
1answer
101 views

Drupal.behavior unexpectedly triggered by Ajax callback

I work on a sandbox project which provides a Responsive Tabs to Accordion Panel style. Everything works fine except that once the page loaded, any Ajax callback (i.e add to cart or colorbox) seems to ...
1
vote
1answer
308 views

Dynamic arguments in an AJAX link

I have a link that uses Drupal's use-ajax CSS class to AJAX-load some node teasers. The callback for the link uses arguments to set a range in the Entity Field Query used to return the teasers: ...
1
vote
1answer
143 views

Need help with Drupal javascript behaviors

I'm a bit lost with this and could do with some help from a Drupal JS veteran. In my module I'm dynamically generating a settings form based on a CSS file, part of which provides a font select list ...
0
votes
0answers
166 views

Custom theme for form checkboxes causes AJAX behaviors to not attach

I have the following code implemented to override the theming for the checkboxes in a Drupal form. //themes neighborhood checkboxes with AJAX link wrapper function ...
0
votes
1answer
597 views

Click event not always fireing in Drupal behaviors

I'm having a strange problem with a form. Sometimes I have to click the submit button twice to make it submit my form. It also seems to work if I click outside the form before I click submit. The form ...
-2
votes
1answer
228 views

behaviours.js syntax (Leaflet Map)

An answer is given here to a problem concerning Leaflet Maps My question: How would I adapt this code (yellow border here) to the syntax of my-theme/my-theme.behaviours.js ? I think it would ...
1
vote
1answer
580 views

How to prevent jQuery from loading during ajax callback

Using Drupal 7's implementation of jQuery and Drupal.behaviors, how can I get some of my jQuery to run only once when the page is initially loaded, and the rest to run when the page is loaded AND ...
1
vote
1answer
567 views

Behaviors/JQuery: What's the standard/convention in Drupal 7 for running Jquery code on event *OTHER* than DOM ready?

Searching online docs so far and I've found much about Drupal Behaviors running when the DOM is ready i.e. the ready JQuery function. But what about for example if I want my JQuery code to run once ...
0
votes
1answer
575 views

Drupal behavior for #datepicker onselect not working

i have a datepicker in a webform. I want to be notified when a date is selected in the datepicker. In my form template i drupal_add_js a js starting with : Drupal.behaviors.booking_form_tma = { ...
5
votes
3answers
8k 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 ...
5
votes
2answers
2k views

How to prevent behavior-attached functions from being attached twice?

I have a behavior that adds on to some checkboxes. (function($) { Drupal.behaviors.mymodule = { attach: function (context, settings) { $('.skip-line', context).on('change', function(){ ...
2
votes
2answers
2k views

How to add behavior-based onclick to ajax-enabled Form API button?

I have a form with a button: $form['categories_update'] = array( '#type' => 'button', '#value' => t('Load category-related properties'), '#ajax' => array( 'callback' => ...
1
vote
0answers
293 views

Rendering Contextual Links after AJAX refresh

We have written a small module that would allow teasers in views reload/refreshed when flagged from inside the contextual links. The names of the flags are 'sold', 'underoffer' and 'withdraw'. The ...
2
votes
1answer
352 views

Form loaded with ajax call not having autocomplete enabled

I have a form (loaded by obiumap function) that have a section loaded ( by function obiumap_addobj() ) with a $.ajax call from jQuery script (addobj.js) by clicking a button (addobj_btn). This new ...
0
votes
1answer
149 views

How can I make teasers refresh when they are flagged?

I have several flags like "Sold" "Withdraw" etc which appear in Contextual links. Flagged nodes are checked through node--type.tpl.php and this allows me to add text strings like "Sold" or ...
2
votes
1answer
99 views

how could I access users profile using settings parameter in drupal behaviours?

I have a behavior as follows: Drupal.behaviors.mymodule = { attach: function(context, settings){ jQuery("#edit-user-address",context).change(function(){ console.log(" user id and other ...
0
votes
2answers
465 views

custom module js loaded before the module which it depends, Drupal.behaviors

The "Drupal.behaviors" doesn't behave as "document.ready", if I use a document.ready I will have the correct map but if I do a Drupal.behaviors, there will be an error related to the openlayers ...