Closed rkyoku closed 5 years ago
@rkyoku no dumb questions! Thanks for asking.
The main reason to encourage using anchor tags is that it is most appropriate HTML tag for the behavior. If you use a <div>
, you lose some of the default behavior and have to reconstruct it manually. For example...
Hope that makes sense. 🍻
I apologize if it is a dumb question or anything, but why on Earth writing a hard-coded limit to anchor tags for the plugin? Is it for ARIA (or other) related reasons that I am not aware of?
As the links will not be followed, they do not need to be links, they lose their semantic role as links. Therefore, IMHO, the plugin should work for any element having a
data-lightbox
attribute.That's what I did by modifying the unminified file on
line 88
from:$('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]', function(event) {
to (yeah I simplified it to its "purest" form):
$('body').on('click', '[data-lightbox]', function(event) {
If you are worried about HTML5 validation errors for putting an
href
attribute to a non-anchor tag, then you could simply add an option likehrefAttribute
so that people could optionally override it to anything (likedata-href
ordata-large-image
or whatever they need).It would add far more flexibility to your plugin.
What concerns me is that I seem to be the only one asking this after eight years (congrats! :) ), which makes me think I might be asking for something stupid... But, well, in any case I modified my version of the plugin so that I don't have to rewrite/pollute all my HTML code and CSS rules in order to use only anchor tags.
Thank you for your input on this! :)
Best,