lightbox icon indicating copy to clipboard operation
lightbox copied to clipboard

Plugin is defined but does not automatically enable

Open groblerf opened this issue 8 years ago • 4 comments

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:

  • link the constructor on the prototype
  • link the constructor on the plugin
  • link the bootstrap data-api
  • add a no conflict (just in case)

groblerf avatar Jan 13 '16 14:01 groblerf

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.

ashleydw avatar Jan 13 '16 15:01 ashleydw

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?

groblerf avatar Jan 13 '16 15:01 groblerf

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

midzer avatar Dec 07 '16 19:12 midzer

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

ashleydw avatar Dec 07 '16 20:12 ashleydw