cbopp-art / lightcase

The smart and flexible Lightbox Plugin.
https://cornel.bopp-art.com/lightcase/
Other
400 stars 106 forks source link

Close link for inline lightcase #177

Open omikron opened 4 years ago

omikron commented 4 years ago

Hello,

Is there any way to call lightcase.close() on a lightcase window opened via the inline tag data-rel="lightcase"?

Thank you

cbopp-art commented 4 years ago

Hi

lightcase.close() can be called from any element or event. However, you have to register it using javascript (not in HTML). The data-rel="lightcase" is just the default (out of the box) identificator for lightcase items. If you want to do advanced stuff, you can also initialize your lightcase links with something else and you will have full control of your HTML elements.

Example:

$( document ).ready(function() {
    $('a[data-rel="your-own-value"]').lightcase('init', {
        'onFinish': {
            // close lightcase automatically
            setTimeout(function () {
                lightcase.close();
            }, 5000);
        }
    });
});

Hope this helps.

f13dev commented 3 years ago

@cbopp-art I have lightcase loading a separate page in an iFrame, is it possible to close the parent lightbox from within the page loaded in the iFrame.

The above example doesn't work for me, nor does running lightcase.close() from an onClick event in the page loaded with lightcase.

Many thanks Jim