Twitter bootstrap 第一次单击后从链接取消绑定引导3模式调用

Twitter bootstrap 第一次单击后从链接取消绑定引导3模式调用,twitter-bootstrap,twitter-bootstrap-3,modal-dialog,unbind,Twitter Bootstrap,Twitter Bootstrap 3,Modal Dialog,Unbind,我无法从ahref元素解除模式事件的绑定: <a id="mzlink_123" href="/merken/123.html" class="btn btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-white glyphicon glyphicon-list-alt"></i> Merken</a> 好的,如果用户再次单击该按钮,则模式不能显示给用户,而是重

我无法从ahref元素解除模式事件的绑定:

<a id="mzlink_123" href="/merken/123.html" class="btn btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-white glyphicon glyphicon-list-alt"></i> Merken</a>
好的,如果用户再次单击该按钮,则模式不能显示给用户,而是重定向到http://www.some.static/site.html

我尝试了以下方法来解决问题:

$('#myModal').on('hide.bs.modal', function (e) {$('a#mzlink_123').unbind('bs.modal');});
不幸的是,它不起作用,模态一次又一次地出现


我很乐意得到一些提示。Thx:)

使用jQuery并删除属性数据切换

$('#mzlink_123').attr("href", "http://www.some.static/site.html");
$('#mzlink_123').removeAttr( "data-toggle" );
如果您需要所有html代码,请参见:

<!DOCTYPE html>
<html>
    <head>        
        <title>DEMO</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">      
    </head>
    <body id="home">
        <a id="mzlink_123" href="/merken/123.html" class="btn btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-white glyphicon glyphicon-list-alt"></i> Merken</a>

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                    </div> 
                </div>
            </div>
        </div>                
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>
        <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>  
        <script type="text/javascript">
            var count = 0;

            $('#mzlink_123').on('click', function(){
                if (count == 1){
                    $('#mzlink_123').attr("href", "http://www.google.ro");
                    $('#mzlink_123').removeAttr( "data-toggle" );
                }
                count++;
            });
        </script>      
    </body>
</html>

演示
情态标题
var计数=0;
$('mzlink_123')。在('click',function()上{
如果(计数=1){
$('#mzlink_123').attr(“href,”http://www.google.ro");
$(“#mzlink_123”).removeAttr(“数据切换”);
}
计数++;
});
  • JSFIDLE
  • JSFIDLE

  • 请注意,JSFIDLE会阻止重定向到另一个网站,这就是为什么我在这里添加了整个html,以便您可以将粘贴复制到文件中,并使其在不进行任何修改的情况下工作。

    我愿意,但我至少需要15分钟。。。很抱歉
    <!DOCTYPE html>
    <html>
        <head>        
            <title>DEMO</title>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
            <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">      
        </head>
        <body id="home">
            <a id="mzlink_123" href="/merken/123.html" class="btn btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-white glyphicon glyphicon-list-alt"></i> Merken</a>
    
            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                        </div> 
                    </div>
                </div>
            </div>                
            <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>
            <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>  
            <script type="text/javascript">
                var count = 0;
    
                $('#mzlink_123').on('click', function(){
                    if (count == 1){
                        $('#mzlink_123').attr("href", "http://www.google.ro");
                        $('#mzlink_123').removeAttr( "data-toggle" );
                    }
                    count++;
                });
            </script>      
        </body>
    </html>