Bug Tracker

Opened 11 years ago

Closed 9 years ago

Last modified 8 years ago

#3930 closed enhancement (wontfix)

Make sure .load() callbacks for images are always called

Reported by: maranomynet Owned by: brandon
Priority: major Milestone: 1.3.1
Component: event Version: 1.3
Keywords: load, trigger, onload, images, event Cc:
Blocked by: Blocking:

Description

It seems that jQuery should perform similar magic when "load" handlers are bound to images, as it does for the "document.ready" - i.e. to trigger the handler if the image is already loaded.

Currently that is not the case (see: http://groups.google.com/group/jquery-dev/browse_thread/thread/24b107e84adeaaee/b0edd6df56a524bb ) and a variety of non-obvious factors may cause the handler to fail to ever run.

Fixing this seems like The jQuery Way to do things - to hide the annoying technical details away from the user.

Change History (7)

comment:1 Changed 9 years ago by dmethvin

Magic is sometimes hard to come by, so patches are welcome...

comment:2 Changed 9 years ago by boushley

I would agree that this would be a nice feature enhancement, but I don't think its a major issue. This script https://github.com/peol/jquery.imgloaded adds a special add function for the load event to jQuery. If we decide this is something we want to handle, we could integrate this code into event.js.

comment:3 Changed 9 years ago by snover

#5983 is a duplicate of this ticket.

comment:4 Changed 9 years ago by snover

Keywords: needsdocs added
Resolution: wontfix
Status: newclosed

Having spent an extreme amount of time and effort with peol trying to come up with a workable way for this to work consistently, it seems that it is basically impossible to make image load events function uniformly across all browsers. If someone can actually demonstrate these unit tests all working properly, then maybe we can move forward with this.

Either way, I am feeling like this is not something that really needs to belong in core as much as documentation needs to exist about caveats of the load event (doesn’t bubble, doesn’t work right in IE, doesn’t fire in WebKit if the src is being set to the same src as before). Someone can reopen this if it’s demonstrated a lot of people really deeply care about this ending up in core.

comment:5 Changed 9 years ago by dmethvin

BTW, the best way to demonstrate that love is to vote up the ticket. *We* will reopen the ticket if it gets enough votes. Of course if you have a patch that passes snover's tests then reopen the ticket, link to your patch, and bask in our adulation.

comment:6 Changed 9 years ago by addyosmani

Updated docs as per snover's comment: http://api.jquery.com/load-event/.

Last edited 9 years ago by addyosmani (previous) (diff)

comment:7 Changed 9 years ago by addyosmani

Keywords: needsdocs removed
Note: See TracTickets for help on using tickets.