我是一个网络开发方面的初学者,在做了很多研究之后,我仍然无法完成这项工作.非常感谢您的帮助.我正在使用最新的rails版本和bootstrap来使事情变得更漂亮.
我有一个页面,上面有一张桌子,上面有一家餐厅的订单.如果你点击一行,我希望它在一个模式窗口中使用 bootstrap 显示订单细节.我已经通过onclick+javascript函数打开了model,但是它看起来有点混乱,我仍然不知道如何用订单信息加载model的content div.以下是我的代码:
HTML:
<h1>Orders</h1>
<table class="table table-striped"
<thead>
<tr>
<th>ID</th>
<th>Customer</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<% @restaurant.orders.each do |order| %>
<tr onclick="orderModal(<%= order.id %>);">
<td><%= order.id %></td>
<td><%= order.customer_id %></td>
<td><%= order.status %></td>
</tr>
<% end %>
</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>
js:
function orderModal(order_id){
$('#orderModal').modal({
keyboard: true,
backdrop: "static"
});
};