javascript 双击表格行时的 Bootstrap 弹出窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28382965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap popup when double click a table row
提问by Asanka sanjaya
I'm have a bootstrap pop up box using this code.
我有一个使用此代码的引导程序弹出框。
<a class="btn btn-default" data-toggle="modal" data-target="#addModal"> test</a>
It is working without having any issue. Now I need to do the same(Appear the same pop up) when user double click on a table row which is in the same page. How can I do this?
它可以正常工作,没有任何问题。现在,当用户双击同一页面中的表格行时,我需要执行相同的操作(出现相同的弹出窗口)。我怎样才能做到这一点?
回答by dfsq
Try this code:
试试这个代码:
$('tr').on('dblclick', function() {
$('#addModal').modal('show');
});
Since modal is already initialized by data attibutes on the button (data-target="#addModal"
), you just need to bind dblclick
event and show modal with .modal('show')
method.
由于 modal 已经由按钮 ( data-target="#addModal"
)上的数据属性初始化,您只需要绑定dblclick
事件并使用.modal('show')
方法显示 modal 。
回答by Akshat
Bind double click event on table row and fire 'show' of bootstrap modal in its callback.
在表格行上绑定双击事件并在其回调中触发引导模式的“显示”。
It should be something like --
它应该是这样的——
$('tr').dblclick(function(){
$('#addModal').modal('show');
})
回答by Muszla
This should work :) listen to double click and after that trigger modal manualy.
这应该有效:) 听双击,然后手动触发模态。
$('.table-row').on('dblclick', function(){
$('#addModal').modal('show')
});