回调函数在bootstrap3的模式 [英] Call back function in modal of bootstrap3

查看:145
本文介绍了回调函数在bootstrap3的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Im有点混乱关于在bootstrap3的javascript模式中启动一个回调函数。在正常 jquery.post 中,您可以像

Im a little bit confuse about firing a call back function in javascript modal of bootstrap3. In normal jquery.post you can do it like,

$.post('path', { something: something }, function(data) { 
  console.log(data);
});

但是在bootstrap 3模态我通过脚本启动模态,我做这样的基础上了解其网站中的说明。

But in bootstrap 3 modal I fires the modal through script and I do it like this base on how I understand the explanation in their website.

$('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的模式中调用回调函数?

But sad to say if I click the button, nothing is happening, nothing was logged in the console. How do I call a callback function in a modal of bootstrap 3?

推荐答案

对于Bootstrap 3,事件现在命名空间, show 事件将为 show.bs.modal ...

For Bootstrap 3, the events are now namespaced, so the show event for the modal would be show.bs.modal...

$('#myModal').on('show.bs.modal', function (e) {
    alert('modal show');
});

演示: http: /bootply.com/90952

这篇关于回调函数在bootstrap3的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆