jQuery: The Write Less, Do More JavaScript Library

Ticket #2139 (closed bug: invalid)

Opened 7 months ago

Last modified 6 months ago

$(window).onunload

Reported by: qutoz Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.2 Component: core
Version: 1.2.1 Keywords:
Cc: Needs: Review

Description

Hi, I'm trying to use the unload event handler with jQuery, but it's not working.
There's no error, but it doesn't fire up.
This is my code:

$(window).unload(function(){
   alert("foo");
 }
)

Attachments

compat_unload_fix.patch (468 bytes) - added by alienbrain 7 months ago.
Unload event fix for compat-1.0 plugin

Change History

Changed 7 months ago by alienbrain

Unload event fix for compat-1.0 plugin

Changed 7 months ago by alienbrain

After some investigation, it turns out that this is a bug in compat-1.0 compatibility plugin.

As it's trying to support the old "un"+event shortcuts, and by doing that it was overriding the unload event when it creates the shortcut for the load event ("un"+"load").

Patch attached above, which fixes this problem. But it would mean that the "un"+"load" shortcut is not available.

Changed 6 months ago by john

  • status changed from new to closed
  • resolution set to invalid

This is correct - or, at least, this is how it behaved in jQuery 1.0.* - so the API is compatible. It's obvious that it's a problem, which is why the API was changed in the first place :-)

Note: See TracTickets for help on using tickets.