Javascript 引导中可单击表行的模式
我有一个三行的表格,我想点击每一行,在一个模式弹出窗口中描述每一行的内容。问题是,当我点击这一行时,屏幕会变暗一些,但不会出现弹出窗口Javascript 引导中可单击表行的模式,javascript,jquery,html,twitter-bootstrap,bootstrap-modal,Javascript,Jquery,Html,Twitter Bootstrap,Bootstrap Modal,我有一个三行的表格,我想点击每一行,在一个模式弹出窗口中描述每一行的内容。问题是,当我点击这一行时,屏幕会变暗一些,但不会出现弹出窗口 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=devi
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
$(function(){
$('#orderModal').modal({
keyboard : true,
backdrop : "static",
show : false,
}).on('show', function(){
var getIdFromRow = $(this).data('orderid');
//make your ajax call populate items or what even you need
$(this).find('#orderDetails').html($('<b> Order Id selected: ' + getIdFromRow + '</b>'))
});
$(".table-striped").find('tr[data-target]').on('click', function(){
//or do your operations here instead of on show of modal to populate values to modal.
$('#orderModal').data('orderid',$(this).data('id'));
});
});
</script>
</head>
<body>
<div class="container">
<h1>Orders</h1>
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Customer</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr data-toggle="modal" data-id="1" data-target="#orderModal">
<td>1</td>
<td>24234234</td>
<td>A</td>
</tr>
<tr data-toggle="modal" data-id="2" data-target="#orderModal">
<td>2</td>
<td>24234234</td>
<td>A</td>
</tr>
<tr data-toggle="modal" data-id="3" data-target="#orderModal">
<td>3</td>
<td>24234234</td>
<td>A</td>
</tr>
</tbody>
</table>
<div id="orderModal" class="modal hide fade" role="dialog" aria-labelledby="orderModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3>Order</h3>
</div>
<div id="orderDetails" class="modal-body"></div>
<div id="orderItems" class="modal-body"></div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</body>
</html>
引导示例
$(函数(){
$('#orderModal').modal({
键盘:没错,
背景:“静态”,
秀:假,,
}).on('show',function(){
var getIdFromRow=$(this).data('orderid');
//让您的ajax调用填充项目或您需要的内容
$(this).find('#orderDetails').html($('orderid selected:'+getIdFromRow+'')
});
$(“.table striped”).find('tr[data target]”)。on('click',function(){
//或者在此处执行操作,而不是在显示模式时,将值填充到模式。
$('#orderModal').data('orderid',$(this.data('id'));
});
});
命令
身份证件
顾客
地位
1.
24234234
A.
2.
24234234
A.
3.
24234234
A.
x
命令
接近
原因是您可能正在使用最新的引导和旧的HTML模式格式
模态应该包括
和
元素。此外,在这个类中不再有hide
类
x
命令
接近
另一件事是,它应该是on('show.bs.modal')
,而不是on('show')
原因是您可能正在使用最新的引导和旧的HTML模式格式 模态应该包括
和
元素。此外,在这个类中不再有hide
类
x
命令
接近
另一件事是,它应该是on('show.bs.modal')
,而不是on('show')
<div id="orderModal" class="modal fade" role="dialog" aria-labelledby="orderModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3>Order</h3>
</div>
<div id="orderDetails" class="modal-body"></div>
<div id="orderItems" class="modal-body"></div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</div>