desandro/imagesloaded — Issue #28: Unbinding imagesLoaded
Author: potench
Created: 2012-03-07 19:37:35+00:00
State: open

What's the proper way to "unbind" the imagesLoaded event/callback?

Scenario: I need to unbind the imagesLoaded callback because I'm nulling the callback before the image has loaded (because the user is impatient and wants to get the next image OR just go to a new page entirely). So the image might load in the time it takes for me to transition-out of a page and remove it from the DOM... meaning it's going to run a callBack unnecessarily or even in error.

Right now I do this to bind/unbind

``` javascript
$("#some-photo").imagesLoaded($.proxy(this.onImagesLoaded, this)); // to bind
$("#some-photo").unbind(); // to unbind.. which sucks for anything else bound here
```

I think I'd like to do

``` javascript
$("#some-photo").bind("load.imagesLoaded error.imagesLoaded", $.proxy(this.onImagesLoaded, this));
$("#some-photo").unbind("load.imagesLoaded error.imagesLoaded", $.proxy(this.onImagesLoaded, this));
```
What do you think?