2013-05-01 69 views
0

我正在做一個ajax調用--->從服務器響應後創建數據--->創建數據表 - >應用數據表---將它追加到DIV - >在該div使用jQuery對話框Jquery UI對話框在關閉時沒有擦除內容

$.ajax({ 
       type: "POST", 
       url: "./poclosed.htm", 
       data: datastring, 
       success: function(data){ 
        //alert("Ajax1"); 
        if(data.status == "SUCCESS") 
         { 
         $('.potable').html("");$('.poorders').html(""); 
         //alert("open "); 
         var po = data.result; 
         //alert(po.length); 
         var podata = ''; 
         var i; 
         podata += '<table id = "potable">'+ 
         '<thead><tr>'+ 
          '<th>col1/th>'+ 
          '<th>col2</th>'+ 
          '<th>col3</th>'+ 
          '<th>col4</th>'+ 
          '<th>col5</th>'+ 
          '<th>col6</th>'+ 
          '<th>col7</th>'+ 
          '<th>col8</th>'+ 
          '<th>col9</th>'+ 
          '<th>col10</th>'+ 
          '<th>col11</th>'+ 
          '<th>col12</th>'+ 
          '<th>col13</th>'+ 
          '<th>col14</th>'+ 
          '<th>col15</th>'+ 
          '<th>col16</th>'+ 
          '<th>col17</th>'+ 
          '<th>col18</th>'+ 
          '<th>col19</th>'+ 
          '<th>col20</th>'+ 
          '<th>Oracle PO. Num</th></tr></thead>'+ 
         '<tbody>'; 

         for( i = 0 ;i < po.length; i++) 
          { 
          podata += '<tr>'+ 
           '<td>'+po[i].col1+'</td>'+ 
           '<td>'+po[i].col2+'</td>'+ 
           '<td>'+po[i].col3+'</td>'+ 
           '<td>'+po[i].col4+'</td>'+ 
           '<td>'+po[i].col5+'</td>'+ 
           '<td>'+po[i].col6+'</td>'+ 
           '<td>'+po[i].col7+'</td>'+ 
           '<td>'+po[i].col8+'</td>'+ 
           '<td>'+po[i].col9+'</td>'+ 
           '<td>'+po[i].col10+'</td>'+ 
           '<td>'+po[i].col11+'</td>'+ 
           '<td>'+po[i].col12+'</td>'+ 
           '<td>'+po[i].col13+'</td>'+ 
           '<td>'+po[i].col14+'</td>'+ 
           '<td></td>'+ 
           '<td>'+po[i].col15+'</td>'+ 
           '<td>'+po[i].col16+'</td>'+ 
           '<td>'+po[i].col17+'</td>'+ 
           '<td>'+po[i].col18+'</td>'+ 
           '<td>'+po[i].col19+'</td>'+              
           '<td>'+po[i].col20+'</td>'+ 
          //'<td>'+po[i].imageNumber+'</td>'+ 
           '</tr>'; 
          } 
         podata += '</tbody></table>'; 
         } 

        //alert(order); 

        $(podata).appendTo('#poorders'); 
       // $('#potable').dataTable(); 
        formatPoSubWindowTable(); 
         $("#poorders").dialog({ 

          width: 1300, 
          left: 25, 
          height: 500, 

         }); 

       }, 
       error: function(e){ 
         alert('Error: ' + e); 
        } 
      }); 

$(本).dialog( '摧毀')remove()方法沒有工作就造成了數據表重新初始化問題 因此,當我讓Ajax調用我得到。帶有新表(應用數據表)的對話框以及舊錶 如果有人可以給出方向,我將非常感激。

+0

爲什麼不只是'$('#poorders')。html(podata)' – 2013-05-01 21:05:32

回答

0

嘗試$('#poorders')。dialog('destroy')。remove()如果您正在尋找轉儲對話框和html。否則,請使用wirey的解決方案來替換內容並避免重新創建對話框。

Jquery.dialog通過檢查單個元素是否已經存在來保護重複的對話框構造。