2012-12-11 61 views
1

jQuery UI的對話框打開回調執行只有一次,但我想它要在每次打開的對話框中一次執行每次..jQuery UI的對話框打開回調執行只有一次,但我想對話框打開

$('<div><b><center>'+ text +'</center></b></div>').dialog({ 
    title: '<b>User(s) with a similar name</b>', 
    modal: true, 
    autoOpen: true, 
    height: 'auto', 
    width: 400, 
    resizable: false, 
    open: function(){ 
    $('#smartpaginate').smartpaginator({ 
     totalrecords: 3, 
     recordsperpage: 2, 
     datacontainer: 'all-tabs', 
     dataelement: 'table', 
     theme: 'green' 
    }); 
    }, 
    buttons: { 
    "Close": function(){ 
     $(this).dialog('close'); 
     return false; 
    } 
    } 
}); 

open的回調函數正確執行並生成分頁,但是在關閉之後,每次打開時都沒有分頁。

+0

,能得到任何JavaScript錯誤? –

+2

你怎樣稱呼open()對話框? 'autoOpen:true'在默認情況下是無用的,它被設置爲true。 –

回答

0

嘗試從DOM刪除對話框:

$('<div><b><center>'+ text +'</center></b></div>').dialog({ 
    title: '<b>User(s) with a similar name</b>', 
    modal: true, 
    autoOpen: true, 
    height: 'auto', 
    width: 400, 
    resizable: false, 
    open: function(){ 
    $('#smartpaginate').smartpaginator({ 
     totalrecords: 3, 
     recordsperpage: 2, 
     datacontainer: 'all-tabs', 
     dataelement: 'table', 
     theme: 'green' 
    }); 
    }, 
    buttons: { 
    "Close": function(){ 
$(this).remove(); 
     return false; 
    } 
    } 
});