2012-11-05 27 views
5

JQuery Mobile simpledialog()從頁面中清除我的動態數據。 其實我有一個列表,我使用simpledialog 提示刪除記錄。但是這將清除我的動態生成列表,所以我必須重新加載 頁面才能返回列表。有沒有什麼選擇擺脫這一點。JQuery Mobile simpledialog從頁面中清除我的動態數據

下面是我的代碼:

$('#Delete').simpledialog({ 

'mode': 'bool', 
'prompt': 'Are you sure to deactivate'?', 
'useModal': true, 
'buttons': { 
    'OK': { 
     click: function() { 
      $('#dialogoutput').text('OK'); 
      $.ajax({ 
       type: 'POST', 
       url: deactivateUrl, 
       data: { postVar: postDeactivate }, 
       beforeSend: function() { 
        showPageLoading("De-Activating.."); 
       }, 
       success: function (data) { 
        hidePageLoading(); 
        if (data = 'true') { 
         notification("Record Deactivated!"); 
         location.reload(); 
        } 
        else { 
         notification("Deactivation failed."); 
        } 
       }, 
       error: function() { 
        //alert("Error"); 
       } 
      }); 

     } 
    }, 
    'Cancel': { 
     click: function() { 
      $('#dialogoutput').text('Cancel'); 
      location.reload(); 
     }, 
     icon: "delete", 
     theme: "c" 
    } 
} 
}); 

回答

0

你,

if (data = 'true') { 
    notification("Record Deactivated!"); 
    location.reload(); 
} 
else 
{ 
    notification("Deactivation failed."); 
} 

此:

if (data = 'true') 

威爾總是是 '真',你將它設置爲「真正'與使用一個等於。

也許你想:

if (data == 'true') 

OR

if (data === true)