How do I close an Inline Dialog from inside the callback function?

I have an InlineDialog that I declare like this:

var inlineDialog = AJS.InlineDialog(AJS.$(this), "dialog-" + appId, function(content, trigger, showPopup) {

                var self = this;

                content.html(Mustache.render(MUSTACHE_TEMPLATES['reset-spam-key-warning'], {}));

    

                // Act upon the delete button

                content.find(".actions .delete-button").click(function(event) {

                    event.preventDefault();

                    console.log("Clicked delete.");

    

                });

    

                showPopup();

            });

I want to write something so that I can close the dialog when the delete button is clicked. How do I make that happen? The problem is that I really don't have access to an inlineDialog close function from in there.

1 answer

1 accepted

1 vote

here's how you cheat:

var inlineDialog;
var closer = function() {
    if (inlineDialog) {
        inlineDialog.hide();
    }
}
inlineDialog = AJS.InlineDialog(..., ..., function(content, trigger, showPopup) {
    // ...
    content.find(...).click(function(e) {
        closer();
    });
});

Nice cheat. Works a charm. I was in the process of trying something similar.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 7 hours ago in Hipchat

Moving from Hipchat to Stride? Here’s what you’ll love

Heya, Hipchat friends! We’re so happy you’re checking out   Stride. Whether you know it or not, you have been instrumental in making Stride come to life. Every feature, design, and functionality...

30 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you