From 50b2e286c9dd6f8b3588a036c47e019dc8fa47e7 Mon Sep 17 00:00:00 2001 From: Francois Grobler Date: Fri, 26 Feb 2016 10:43:11 +0200 Subject: [PATCH] NoConflict and binding to Bootstrap data-api Created a data-api binding for ekkoLightbox so that the add-in will be applied automatically to any element with a data-toggle="lightbox" This assists with dynamically created elements that are loaded via ajax to be bound to the data-api when bootstrap parses the new elements. --- dist/ekko-lightbox.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dist/ekko-lightbox.js b/dist/ekko-lightbox.js index a662601..41e2767 100644 --- a/dist/ekko-lightbox.js +++ b/dist/ekko-lightbox.js @@ -405,6 +405,8 @@ License: https://github.com/ashleydw/lightbox/blob/master/LICENSE } }; + //Save a possible conflicting lightbox + var old = $.fn.ekkoLightbox; $.fn.ekkoLightbox = function(options) { return this.each(function() { var $this; @@ -437,4 +439,20 @@ License: https://github.com/ashleydw/lightbox/blob/master/LICENSE onContentLoaded: function() {} }; + $.fn.ekkoLightbox.Constructor = EkkoLightbox; + + // MODAL DATA-API + // ============== + $(document).on('click.bs.ekkoLightbox.data-api', '[data-toggle="lightbox"]', function (e) { + event.preventDefault(); + $(this).ekkoLightbox(); + }); + + // MODAL NO CONFLICT + // ================= + $.fn.ekkoLightbox.noConflict = function () { + $.fn.ekkoLightbox = old; + return this; + } + }).call(this);