我对在 bootstrap3 的 javascript 模式中触发回调函数有点困惑。在正常的 jquery.post
中,你可以这样做,
$.post('path', { something: something }, function(data) {
console.log(data);
});
但是在 bootstrap 3 模态中,我通过脚本触发模态,并且根据我对他们网站中的解释的理解,我这样做了。
$('selector').modal('show', function() {
//here comes the problem, I have a button in the modal in the html, my code
//if the button was clicked inside this modal is..
$('#myButton').on('click', function() {
console.log("this is a try");
});
});
但遗憾的是,如果我单击按钮,什么也没有发生,控制台中也没有记录任何内容。如何在bootstrap 3的模态中调用回调函数?
最佳答案
对于 Bootstrap 3,事件现在已命名,因此模式的 show
事件将为 show.bs.modal
...
$('#myModal').on('show.bs.modal', function (e) {
alert('modal show');
});
关于jquery - bootstrap3模态中的回调函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19676392/