control javascript behaviors order
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? Thanks and best wishes, Jack
2008/3/7, Jack Bates <ms419@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); Henrique
On Fri, Mar 7, 2008 at 7:23 PM, Jack Bates <ms419@freezone.co.uk> wrote:
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?
There are some "hacks" in Drupal 6 around textarea resizing and teasers to ensure proper ordering, basically calling out to the behavior to run first, if the second one finds out (by looking for a class) that the first did not run yet. Gabor
participants (3)
-
Gábor Hojtsy -
Henrique Recidive -
Jack Bates