diff --git a/.gitignore b/.gitignore index 15cdb46..ad878bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ .idea archive node_modules -_SpecRunner.html \ No newline at end of file +_SpecRunner.html + +*.sublime-project +*.sublime-workspace \ No newline at end of file diff --git a/src/jail.js b/src/jail.js index 32073d1..3ed5ec3 100644 --- a/src/jail.js +++ b/src/jail.js @@ -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"); }