Javascript Jquery完全关闭引导模式对话框
下面是我使用jquery关闭引导模式的代码Javascript Jquery完全关闭引导模式对话框,javascript,jquery,css,twitter-bootstrap,Javascript,Jquery,Css,Twitter Bootstrap,下面是我使用jquery关闭引导模式的代码 //Start to hide bootstrap modal $('#continue-last-level').modal('hide'); //Line 1 //End //Codes to execute another function $.ajax({ //Line 2 url : '/qst/continue_last_level/',
//Start to hide bootstrap modal
$('#continue-last-level').modal('hide'); //Line 1
//End
//Codes to execute another function
$.ajax({ //Line 2
url : '/qst/continue_last_level/',
type : 'post',
dataType: 'JSON',
data : 'performance_level='+performance_level,
success : function (data)
{
localStorage.setItem("key", 60*3*data.total_questions);
localStorage.setItem("question_id", data.first_question_id);
localStorage.setItem("question_number", data.question_number);
view_question_template(performance_level);
}
});
}
//End code
我的问题是在执行第1行的代码后,我想执行第2行的代码,引导模式已隐藏,但仍有一个div未隐藏。。。这是我的屏幕简图供你参考
图1
在我点击yes之后…假设调用函数来执行第2行的代码,模态被隐藏了,但是。。。
隐藏方法是异步的: 手动隐藏模态在模式实际隐藏之前返回调用方(即
隐藏.bs.modal
事件发生之前)
因此,您需要在代码中说明这一点,并使用Bootstrap提供的hidden
事件:
$('#continue-last-level').one('hidden.bs.modal', function () {
// modal is now hidden
// your code here
}).modal('hide');
$('#continue-last-level').one('hidden.bs.modal', function () {
// modal is now hidden
// your code here
}).modal('hide');