2011-12-15 86 views
0

我怎樣才能延緩對話框加載像2-3秒jquery延遲對話框加載?

$("#dialog-model").dialog({ 
    height: 250, 
    width: 350, 
    buttons: { 
     "Yes": function() { 
      window.location = "/MyURL"; 
     }, 
     "No": function() { 
      $(this).dialog('close'); 
     } 
    }, 
    modal: true 
}); 

回答

2

使用的setTimeout

var seconds=3000; 
setTimeout(
function(){ 
    $("#dialog-model").dialog({ 
     height: 250, 
     width: 350, 
     buttons: { 
      "Yes": function() { 
       window.location = "/MyURL"; 
      }, 
      "No": function() { 
       $(this).dialog('close'); 
      } 
     }, 
     modal: true 
    }); 
},seconds);