How to programmatically trigger an AJS inline dialog?

Frédéric Tardieu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2014

Hi all,

I see in the AUI Sandbow an example that triggers an inline dialog when a button is pressed:

AJS.InlineDialog(AJS.$("#popupLink"), 1,
    function(content, trigger, showPopup) {
        content.css({"padding":"20px"}).html('<h2>Inline dialog</h2><p>The inline dialog is a wrapper for secondary content/controls to be displayed on user request. Consider this component as displayed in context to the triggering control with the dialog overlaying the page content.</p><button class="aui-button">Done</button></form>');
        showPopup();
        return false;
    }
);

But how to do to trigger this inline dialog from execution of a JS method?

Thanks,

Fred

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2014

If you already have the trigger element you can just fire the click event yourself, eg in the aui sandbox example:

AJS.$("#popupLink").trigger('click')

Frédéric Tardieu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2014

Problem is that the trigger element is a button which should do something else than showing the dialog when clicked manually. So if I use .trigger('click'), then this will trigger its already defined function.

So, I need to be able to show the inline dialog, calling any method but trigger('click')...

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2014

Can you put the button inside a div, attach the inline dialog to the div, then trigger the click on the div...?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2014

http://jsfiddle.net/5Hb8S/

Click run, doesn't seem to work right on the initial load.

Frédéric Tardieu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2014

Hi Jamie,

Seems OK (it runs on initial load on my side), thank you for the tip!

0 votes
RDK October 12, 2014
var dialog = AJS.InlineDialog(...);
dialog.show();
TAGS
AUG Leaders

Atlassian Community Events