Skip to content

Commit

Permalink
Added Image.onerror handler and options.error callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
goliatone committed May 16, 2013
1 parent 3878b92 commit 38f81db
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/jail.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,22 @@
isCallbackDone = true;
}
};

/*
* Basic on error handler. For now we limit
* the plugin to exectute any callback passed
* in the options object. Let the developer
* decide what to do with it.
*/
cache.onerror = function(){

if(!('error' in options)) return;

var args = Array.prototype.slice.call(arguments, 0);
args = [$img, options].concat(args);
options.error.apply($.jail, args);
};

cache.src = $img.attr("data-src");
}

Expand Down

0 comments on commit 38f81db

Please sign in to comment.