electerious / basicLightbox

The lightest lightbox ever made.

Home Page:https://basiclightbox.electerious.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Closing when defined in a function

adam-jones-net opened this issue · comments

Having a really simple problem. I'm trying to generate via a function and find that the close command doesn't work.

So I define global variable, then within the function try to update it whenever called.

var popup="";
function testPopup(content){
	popup=basicLightbox.create(content+` - <span class="btnClose">CLOSE</span>`).show();
}

Then to catch the close button click...

$(document).ready(function() {
     $(document).on('click','.btnClose', function(event){
        popup.close();
    });
});

When I click the close button I get popup.close is not a function msgs.

The show function isn't returning an instance. You can do it like this:

var popup="";
function testPopup(content){
	popup=basicLightbox.create(content+` - <span class="btnClose">CLOSE</span>`);
	popup.show();
}

Hope that helps :)

Ah damm i thought it was something simple thanks! ;)