2015-06-14 116 views

回答

1

檢查出來here

Bootbox定義它們的功能here,正如你可以看到他們有一個回調。例如:

bootbox.alert(message, callback) 

callback讓你只運行某些代碼的選項,一旦這條線就完成了。這解決了你的問題。

JS

$(document).ready(function() { 
    $('.begin-game').click(function() { 
     bootbox.alert("This should show up first", function() { 
      bootbox.dialog({ 
       message: "Did you pass Go?", 
       title: "This should go second/last", 
       buttons: { 
        // Passed go 
        success: { 
         label: "Yes I Passed GO!", 
         className: "btn-success", 
         callback: function() { 

         } 
        }, 
        // Did not pass go 
        danger: { 
         label: "I did not :(", 
         className: "btn-danger", 
         callback: function() { 

         } 
        }, 
       } 
      }); 
     }); 
    }); 
}); 
0

bootbox.alert的第二個參數是一個function警報被駁回後,將調用。在該功能中啓動對話框。

$(document).ready(function() { 
    $('.begin-game').click(function() { 
     bootbox.alert("This should show up first", showDialog); 

     function showDialog() { 
      bootbox.dialog({ 
       message: "Did you pass Go?", 
       title: "This should go second/last", 
       buttons: { 
        // Passed go 
        success: { 
         label: "Yes I Passed GO!", 
         className: "btn-success", 
         callback: function() { 

         } 
        }, 
        // Did not pass go 
        danger: { 
         label: "I did not :(", 
         className: "btn-danger", 
         callback: function() { 

         } 
        } 
       } 
      });   
     } 
    }); 
});