Skip to content

Commit 4dafef4

Browse files
committed
trigger 'load' event in addons
1 parent d534669 commit 4dafef4

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/jquery.lazyloadxt.bg.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
if (!!url) {
1616
$this
1717
.css('background-image', "url('" + url + "')")
18-
.removeAttr(bgAttr);
18+
.removeAttr(bgAttr)
19+
.triggerHandler('load');
1920
}
2021
});
2122

src/jquery.lazyloadxt.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@
207207
}
208208

209209
if (visible) {
210+
$el.on(load_error, triggerLoadOrError);
211+
210212
triggerEvent('show', $el);
211213

212214
var srcAttr = objData.srcAttr,
213215
src = $isFunction(srcAttr) ? srcAttr($el) : el.getAttribute(srcAttr);
216+
214217
if (src) {
215-
$el.on(load_error, triggerLoadOrError);
216218
el.src = src;
217-
} else {
218-
triggerEvent('load', $el);
219219
}
220220

221221
removeNode = true;

src/jquery.lazyloadxt.widget.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@
1212

1313
$(document).on('lazyshow', '[' + widgetAttr + ']', function () {
1414
var $this = $(this),
15+
$target = $this,
1516
id = $this.attr(widgetAttr),
1617
match;
1718

1819
if (id) {
19-
$this = $('#' + id);
20+
$target = $('#' + id);
2021
}
2122

22-
if ($this.length) {
23-
match = reComment.exec($this.html());
23+
if ($target.length) {
24+
match = reComment.exec($target.html());
2425
if (match) {
25-
$this.replaceWith($.trim(match[1]));
26+
$target.replaceWith($.trim(match[1]));
2627
}
2728
}
29+
30+
$this.triggerHandler('load');
2831
});
2932

3033
})(window.jQuery || window.Zepto || window.$);

0 commit comments

Comments
 (0)