0

I am loading one page via jQuery Mobile dialog widget and if i use popup messages in loaded page i cant close it after popup on ios 6.1.2. Here is an example:

jQuery.post(
    ajax_url+'create',
    {'info': send_values},
    function(result){
        if(result.status){
            //Without this message all works fine
            jQuery('#popup-message').text(result.message).popup('open');
            setTimeout(function(){
                // Tried
                // jQuery('#popup-error').popup('close');
                // jQuery('#popup-message').popup('close');
                // jQuery('.ui-dialog').dialog('close');
                jQuery('#dialog').dialog('close'); //loaded div is with dialog id
            }, 2000);
        }
        else
            showError(result.message);
    },
    'JSON'
)
user1692333
  • 2,461
  • 5
  • 32
  • 64

1 Answers1

0

EDIT:

The question is how to close a dialog after being opened from within a popup

Ok, now I got it ;)

So there is a event you can listen for that is called after a popup is opened

$( ".Selector" ).on( "popupafteropen", function( event, ui ) {} );

src:http://api.jquerymobile.com/popup/#event-afteropen

So your code updated should be:

jQuery.post(
ajax_url+'create',
{'info': send_values},
function(result){
    if(result.status){
        //Without this message all works fine
        jQuery('#popup-message').text(result.message).popup('open');
        jQuery('#popup-message').on('popupafteropen', function( event, ui ) {
            setTimeout(function(){
                // Tried
                // jQuery('#popup-error').popup('close');
                // jQuery('#popup-message').popup('close');
                // jQuery('.ui-dialog').dialog('close');
                jQuery('#dialog').dialog('close'); //loaded div is with dialog id
            }, 2000);
        } );
    }
    else
        showError(result.message);
},
'JSON'
)

Original Answer:

You are trying to close a DIALOG...however you opened a POP-UP.

Change:

 jQuery('#dialog').dialog('close'); //loaded div is with dialog id

To:

 jQuery('#dialog').popup('close'); //loaded div is with dialog id

src: http://api.jquerymobile.com/popup/#method-close

Red2678
  • 3,177
  • 2
  • 29
  • 43