ashleydw / lightbox

A lightbox gallery plugin for Bootstrap
http://ashleydw.github.io/lightbox
MIT License
1.84k stars 1.3k forks source link

Plugin is defined but does not automatically enable #160

Open groblerf opened 8 years ago

groblerf commented 8 years ago

Additional java script is required to "activate" the plugin. This should rather happen as part of the inclusion of the plugin.

It is simple to do, just:

ashleydw commented 8 years ago

What do you mean "activate"? Do you mean include the delegate code that is in the documentation under "Implementation"?

This is how it was originally but it can cause conflicts with other libraries so was removed.

groblerf commented 8 years ago

Hi Ashley, Yes that is what I mean. Is'nt it better to just add a "NoConflict" function that can be used by those where a conflict exists? Add a variable before the plugin is declared to that any old conflicting plugin can be returned

 var old = $.fn.ekkoLightbox;
  $.fn.ekkoLightbox = function(options) {

Then add a noConflict function for the case where a conflict occurs.

  $.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;
  }

This makes implementation of the plugin consistent with other plugins. Don't you agree?

midzer commented 7 years ago

There is a PR for this issue https://github.com/ashleydw/lightbox/pull/178

ashleydw commented 7 years ago

the automatic binding wasn't added as it would be a breaking change from current system where manual instantiation is required

noConflict concern has been addressed in latest version 5 for BS4