I
I
Ilyaploskov2019-03-09 18:12:45
UIkit
Ilyaploskov, 2019-03-09 18:12:45

How to apply UIkit.lightbox to links with a specific class?

Foreword: Joomla had a separate plugin for lightbox. But the template on UIkit3. Recently, I began to study UIkit, and saw a good lightbox there. I decided to get rid of the plugin and implement the lightbox built into UIkit3.
The documentation says

<div uk-lightbox>
    <a href="image.jpg" data-caption="Caption"></a>
</div>

But I don’t want to wrap each image in a div, since there are a lot of them on the pages. As a result, I registered "uk-lightbox" for the container of the entire article, but simple links began to load in the lightbox.
How to initialize UIkit.lightbox so that it only applies to links with a certain class?
What can be done? Thank you

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2019-07-08
@asuikit

What's with the whole article? Read UIkit 3 Documentation - Lightbox

K
Kosting, 2020-05-22
@Kosting

if still relevant, I had a similar situation -
a list of photos and links under them, you only need to display the photos in the lightbox.
It turns out to be easy to do this, you need to set the uk-lightbox option "toggle: css-selector", where css-selector can be any tag or the same awith a specific class:

<div uk-lightbox="toggle: a.lbox">

  <div class="item">
      <a class="lbox" href="img.jpg">
         <img src="img.jpg">
      </a>
      <a href="item.php">Title item</a>
   </div><!-- ./item -->
    
   ...
  </div>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question