V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lbfeng
V2EX  ›  jQuery

bootstrap modal event 多次绑定

  •  
  •   lbfeng · 2016-06-21 06:06:50 +08:00 · 3420 次点击
    这是一个创建于 2859 天前的主题,其中的信息可能已经有所发展或是发生改变。
        <div id="exampleModal"> 。。。</div>
        <button data-toggle="modal" data-target="#exampleModal"></button>
        
        $('#exampleModal').on('show.bs.modal', function(event) {
        	$.ajax(...);
            $(this).modal('hide');
        });
    

    第一次打开窗口会有一次 ajax ,不刷新,第二次打开窗口会有两次 ajax 。是因为$('#exampleModal')重复捆绑 modal 。怎样才能在不刷新前提下多次打开窗口但只绑定一个 modal 。

    第 1 条附言  ·  2016-06-21 07:10:05 +08:00
    已搞定
    3 条回复    2017-03-12 18:42:25 +08:00
    fising
        1
    fising  
       2016-06-21 08:15:42 +08:00 via iPhone
    每次都先 unbind ,应该有更好的办法
    fising
        2
    fising  
       2016-06-22 11:48:10 +08:00
    @lbfeng 怎么解决的呢
    xx19941215
        3
    xx19941215  
       2017-03-12 18:42:24 +08:00
    怎么弄的,我也遇到了类似的情况!!!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5524 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:27 · PVG 11:27 · LAX 20:27 · JFK 23:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.