jQuery Mobile关闭页面对话框

Ber*_*ris 5 html jquery jquery-mobile

如何在jQuery Mobile中关闭对话框页面?

在我的特殊情况下,我调用另一个页面作为页面加载,然后在完成该过程之后我想将ajax页面加载关闭并再次出现一个包含所有数据的对话框页面回调ajax.

我的代码:

$("#login").click(function(e){
LoadingPanel();
e.preventDefault();
     $.ajax({
        url:'http://www.myurl.com/soap/login.php',
        dataType:'jsonp',
        timeout: 15000,
        cache: false,
        data: dataString,
        success:function(response){

            //Dialog page closed here

            for(var i=0; i<response.length; i++){
                    var str,str2,str3,str4,str5,str6,str7 = "";
                    str     = response[i].NE;
                    str2    = response[i].EMAIL;
                    str3    = response[i].TIPE;
                    str4    = response[i].NAMA;
                    str5    = response[i].TELP;
                    str6    = response[i].DN;
                    str7    = response[i].DESC_LOGIN;


                if(str=='-'){
                    alert('Data does not match')
                }else{
                var AllData = ""
                    AllData = 'Data1 : '+str+'\nData2 : '+str2+'\nData3 : '+str3+'\nData4 : '+str4+'\nData5 : '+str5
                    alert(AllData);
                    //How do I display this data into jquery mobile dialog?
                    } 
                }

            },
            error: function (xhr, ajaxOptions, thrownError) {
                if(thrownError==="timeout") {
                    alert("Cant connect");
                } else {
                    alert(t);
                }
            }
    });
  });
Run Code Online (Sandbox Code Playgroud)

到调用页面加载:

function LoadingPanel(){
    $.mobile.changePage( "loading.html", { 
       role: "dialog" 
    });
}
Run Code Online (Sandbox Code Playgroud)

当我的数据成功接受 - > alert(AllData)时,如何将此数据显示到jquery移动对话框中?

Oma*_*mar 6

一旦你加载loading.html使用$.mobile.changePage('loading.html', { role: 'dialog'});,jQuery Mobile将给它一个data-role=dialog.您可以使用以下方法关闭它.

$('[data-role=dialog]').dialog( "close" );
Run Code Online (Sandbox Code Playgroud)

这将关闭对话框,实际上是任何打开的对话框,即使它没有id.

.selector意思,#id.class,data-role=something......等