Skip to content

Commit

Permalink
Merge pull request sebarmeli#40 from goliatone/onerror_handler
Browse files Browse the repository at this point in the history
Added onerror handler to _loadImage. Optional callback provided in options object.
  • Loading branch information
sebarmeli committed May 16, 2013
2 parents 251b771 + 38f81db commit b6bdb16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.idea
archive
node_modules
_SpecRunner.html
_SpecRunner.html

*.sublime-project
*.sublime-workspace
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 b6bdb16

Please sign in to comment.