From 92d48e7ad71000a5a3122a258b0e5f7c38420a05 Mon Sep 17 00:00:00 2001 From: ZZZero <914426031@qq.com> Date: Mon, 25 May 2015 16:08:13 +0800 Subject: [PATCH] Add settings.error Add settings.error,If the url for picture is error. method load can't run. --- jquery.lazyload.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jquery.lazyload.js b/jquery.lazyload.js index 26fab660..f7b1f28e 100644 --- a/jquery.lazyload.js +++ b/jquery.lazyload.js @@ -29,7 +29,8 @@ skip_invisible : false, appear : null, load : null, - placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" + placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC", + error : null }; function update() { @@ -127,7 +128,13 @@ settings.load.call(self, elements_left, settings); } }) - .attr("src", $self.attr("data-" + settings.data_attribute)); + .attr("src", $self.attr("data-" + settings.data_attribute)) + .bind("error", function(){ + if (settings.error) { + var elements_left = elements.length; + settings.error.call(self, elements_left, settings); + } + }); } });