lbfeng
V2EX  ›  jQuery

bootstrap modal event 多次绑定

  •  
  •   lbfeng · Jun 21, 2016 · 4466 views
    This topic created in 3809 days ago, the information mentioned may be changed or developed.
        <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 。

    Supplement 1  ·  Jun 21, 2016
    已搞定
    3 replies  •  2017-03-12 18:42:25 +08:00
    fising
    fising
    Jun 21, 2016 via iPhone
    1
    每次都先 unbind ,应该有更好的办法
    fising
    fising
    Jun 22, 2016
    2
    @lbfeng 怎么解决的呢
    xx19941215
    xx19941215
    Mar 12, 2017
    3
    怎么弄的,我也遇到了类似的情况!!!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   969 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 22:22 · PVG 06:22 · LAX 14:22 · JFK 17:22
    ♥ Do have faith in what you're doing.