1

I'm tring to create a jquery ui dialog without having a empty div container for the dialog in the HTML. For some reason, the global variable isn't recognized in other javascript functions (besides the original javascript function).

var $signOutDialog = null;


function createDialog() {
    var $signOutDialog = $("<p></p>").dialog({
        resizable: false,
        title: 'Sign Out',
        width: 830,
        autoOpen: false,
        modal: true,

    });
}

and then i have another javascript function which gets called as a result of a $.ajax success delegate. the $signOutDialog global variable is NULL in this function.

 function test2() {
     $signOutDialog.dialog('close'); 
 }

any known solution for closing a jquery ui dialog without having the dialog as an empty html element?

2 Answers 2

2

Remove the var before $signOutDialog in the function, you define it again in the function as a local variable in the function's scope.

Sign up to request clarification or add additional context in comments.

Comments

1

the global $signOutDialog is a regular javascript variable.

The $signOutDialog inside the createDialog, is a different than the previous one.

so in the test2 method, it try to ".dialog('close')" on a null.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.