Fire Confirm dialog from javascript

Jul 9, 2012 at 7:16 PM

Hi,

For the autocomplete package I have also implemented search & replace.

I use a (javascript) confirm() from javascript - which is basically ugly. Also does Firefox attach the 'no more alerts..' checkbox and I need to display this alert multiple time, i.e. on each replace.

What's the correct way to add a Composite confirm dialog?

thnx in advance,

JamBo

Developer
Jul 10, 2012 at 7:06 AM
Edited Jul 10, 2012 at 7:07 AM

Composite confirm function:

 

                                Dialog.question (
                                        'Title',
                                        'Text...',
                                        Dialog.BUTTONS_ACCEPT_CANCEL,
                                        {
                                                handleDialogResponse : function ( response ) {
                                                        if ( response == Dialog.RESPONSE_ACCEPT ) {
                                                                //Do Smth...
                                                        }
                                                }
                                        }
                                );



OR

                 Dialog.question (
                        'Title',
                        'Text....',
                        Dialog.BUTTONS_YES_NO_CANCEL, {
                        handleDialogResponse : function ( response ) {
                                switch ( response ) {
                                        case Dialog.RESPONSE_YES :
                                                // Do Smth...
                                                
                                                break;
                                        case Dialog.RESPONSE_NO :
                                                // Do Smth...
                                                break;
                                }
                        }
                });

 
Jul 10, 2012 at 9:50 AM

@neex,

Thnx.

Got it working. I needed however to access to the dialog from a script within the code editor.
For any one needing this in the future. The required Dialog.js lives in the top window (core) and can be addressed by window.top:

// Ask the user
window.top.Dialog.question( 'Replace',
                            'Replace?',
                            window.top.Dialog.BUTTONS_ACCEPT_CANCEL,
                            {
                                handleDialogResponse: function (response)
                                {
                                    if (response == window.top.Dialog.RESPONSE_ACCEPT)
                                    {
                                        doReplace(match);
                                    }
                                    else
                                    {
                                        advance();
                                    }
                                }
                            }
                        );