Skip to content

Commit 7047214

Browse files
committed
Prevent enable and build methods from running ahead of dom ready
1 parent 2422bd7 commit 7047214

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/js/lightbox.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@
6161
};
6262

6363
Lightbox.prototype.init = function() {
64-
this.enable();
65-
this.build();
64+
var self = this;
65+
// Both enable and build methods require the body tag to be in the DOM.
66+
$(document).ready(function() {
67+
self.enable();
68+
self.build();
69+
});
6670
};
6771

6872
// Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes

0 commit comments

Comments
 (0)