dialog - Get instance of JQuery UI popup -


i creating jquery ui popup way:

function showjquerystandarddialog(searchtarget, title, width, height, closefunction) {     var $dialog = $('<div id="dialogdiv"><iframe id="dialogiframe" frameborder="no" scrolling="auto" src="' + searchtarget + '" width="' + (width - 50) + 'px" height="' + (height - 50) + 'px"></iframe></div>');      $dialog.dialog(     {         modal: true,         title: title,         show: 'slide',         width: width,         height: height,         closeonescape: true,         close: function (event, ui)         {             if (typeof closefunction === 'function') closefunction();         }     }); } 

i want instance of popup elsewhere in code can close it. tried:

var $dialog = $('#dialogdiv'); var $dialog = $('.ui-dialog'); var $dialog = $('.ui-dialog-content'); 

but returns empty object. note if put above code in close method of dialog, works fine. shall conclude can't access popup outside init code?

found way:

function showjquerystandarddialog(searchtarget, title, width, height, closefunction) {     $dialog = $('<div id="dialogdiv"><iframe id="dialogiframe" frameborder="no" scrolling="auto" src="' + searchtarget + '" width="' + (width - 50) + 'px" height="' + (height - 50) + 'px"></iframe></div>');      $dialog.dialog(     {         modal: true,         title: title,         show: 'slide',         width: width,         height: height,         closeonescape: true,         close: function (event, ui)         {             if (typeof closefunction === 'function') closefunction();         }     });      /* important bit */     $(document).bind('close-dialog', function ()     {         $dialog.dialog('close');     }); } 

then call parent.$(parent.document).trigger('close-dialog'); when want close dialog.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -