Skip to main content

Bug Tracker

Side navigation

#3930 closed enhancement (wontfix)

Opened January 20, 2009 11:24PM UTC

Closed November 03, 2010 05:42PM UTC

Last modified March 15, 2012 02:44PM UTC

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.

Attachments (0)
Change History (7)

Changed June 22, 2010 03:20AM UTC by dmethvin comment:1

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

Changed November 03, 2010 03:59PM UTC by boushley comment:2

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.

Changed November 03, 2010 05:36PM UTC by snover comment:3

#5983 is a duplicate of this ticket.

Changed November 03, 2010 05:42PM UTC by snover comment:4

keywords: load, trigger, onload, images, eventload, trigger, onload, images, event needsdocs
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.

Changed November 03, 2010 06:02PM UTC by dmethvin comment:5

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.

Changed April 19, 2011 06:08AM UTC by addyosmani comment:6

_comment0: Updated docs as per snover's comment: http://api.jquery.com/load-event/. Leaving needsdocs in place in case these points need to be further expanded on.1305663575903978

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

Changed May 17, 2011 08:19PM UTC by addyosmani comment:7

keywords: load, trigger, onload, images, event needsdocsload, trigger, onload, images, event