[development] control javascript behaviors order

Henrique Recidive recidive at gmail.com
Fri Mar 7 19:45:15 UTC 2008

2008/3/7, Jack Bates <ms419 at freezone.co.uk>:
> I have one Drupal 6 JavaScript behavior which must be run before another
>  behavior, however the JavaScripts which set `drupal.behaviors.x` are
>  included in the page in the opposite order. Consequently the behaviors
>  are called in the wrong order.
>  I did a little googling and read the section of drupal.js responsible
>  for calling behaviors, but haven't found any techniques for controlling
>  the order of behaviors. Do any techniques for controlling the order of
>  behaviors currently exist, or are any planned?

Can't you just include you .js file in the correct order you want?

If not try this to prepend you behavior to Drupal.behaviors object:

var yourBehavior = function(context) {
  // your behavior code here.

Drupal.behaviors = $.extend({yourBehavior: yourBehavior}, Drupal.behaviors);


More information about the development mailing list