微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery – 以bootstrap3为模式回调函数

对于在bootstrap3的 javascript模式中启动一个回调函数,我有点混乱.在正常的jquery.post中,你可以这样做,
$.post('path',{ something: something },function(data) { 
  console.log(data);
});

但是在引导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");
  });
});

但不幸的是,如果我点击按钮,没有任何事情发生,没有任何记录在控制台.如何在一个引导模式3中调用回调函数

解决方法

对于Bootstrap 3,事件现在是命名空间,所以模态的show事件将是show.bs.modal …
$('#myModal').on('show.bs.modal',function (e) {
    alert('modal show');
});

演示:http://bootply.com/90952

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐