I have a module that binds the 'click' event to a checkbox. When I enable the autologout module, my event is unbound by autologout.js:
// Make form editing keep the user logged in.
var events = 'change click blur keyup';
$('body')
.find(':input').andSelf().filter(':input')
.unbind(events).bind(events, function () {
activity = true;
});
This breaks my own module's functionality. Looking at the page source, I see that my module's javascript is being loaded before autologout.js. (My module's .js file is loaded via drupal_add_js() in hook_init().)
There are 2 solutions I can think of:
1) autologout should maintain existing events, and not unconditionally unbind everything
2) autologout should ensure that autologout.js loads before the javascript provided by other modules & themes
I'm not sure what the preferred solution is. I personally wouldn't be confident trying to provide solution #1 (I've been to ie7/8 hell before). Solution #2 would be pretty simple to achieve by using drupal_add_js()'s "type" parameter to control the order (D6), or the "weight" option for D7.
ie: in D6, use the 'core' type to ensure it's loaded before module and theme:
drupal_add_js(drupal_get_path('module', 'autologout') . "/autologout.js", 'core');
Thoughts?
Comment | File | Size | Author |
---|---|---|---|
#1 | autologout-remove_unconditional_unbind_events-2085827-1.patch | 414 bytes | johnennew |
Comments
Comment #1
johnennew CreditAttribution: johnennew commentedHi @ryan_courtnage - thanks for your report, sorry its taken a while to reply.
I'm not sure about option 2, I don't think contrib should be declaring its js as core.
I think i copied the unbind().bind() pattern blindly from some other code - I don't think it will hurt to remove it. The 7.x-4.x version doesn't actually do this and appears to work.
Is anyone able to test the attached patch for 6.x-4.x?
Comment #2
wdouglascampbell CreditAttribution: wdouglascampbell commentedI tested the attached patch and it does resolve the issue when I encountered it. Thanks!
Comment #3
johnennew CreditAttribution: johnennew commentedThanks for the review!
Committed to 6.x-4.x-dev