我正在开发一个ASP.Net MVC
站点,在该站点上,我在一个表中列出了来自数据库查询的一些预订,其中包含一个ActionLink
,用于取消具有特定BookingId
的特定行上的预订,如下所示:
My bookings
<table cellspacing="3">
<thead>
<tr style="font-weight: bold;">
<td>Date</td>
<td>Time</td>
<td>Seats</td>
<td></td>
<td></td>
</tr>
</thead>
<tr>
<td style="width: 120px;">2008-12-27</td>
<td style="width: 120px;">13:00 - 14:00</td>
<td style="width: 100px;">2</td>
<td style="width: 60px;"><a href="/Booking.aspx/Cancel/15">cancel</a></td>
<td style="width: 80px;"><a href="/Booking.aspx/Change/15">change</a></td>
</tr>
<tr>
<td style="width: 120px;">2008-12-27</td>
<td style="width: 120px;">15:00 - 16:00</td>
<td style="width: 100px;">3</td>
<td style="width: 60px;"><a href="/Booking.aspx/Cancel/10">cancel</a></td>
<td style="width: 80px;"><a href="/Booking.aspx/Change/10">change</a></td>
</tr>
</table>
如果我可以使用jQuery Dialog
弹出一条消息,询问用户是否确定要取消预订,那就太好了。我一直在尝试让它正常工作,但是我一直纠结于如何创建一个接受参数的jQuery函数,这样我就可以替换
<a href="/Booking.aspx/Cancel/10">cancel</a>
使用
<a href="#" onclick="ShowDialog(10)">cancel</a>
。
然后,href函数将打开对话框,并将参数10传递给对话框,以便如果用户单击yes,则它将发布ShowDialog
:/Booking.aspx/Change/10
我在脚本中创建了jQuery对话框,如下所示:
$(function() {
$("#dialog").dialog({
autoOpen: false,
buttons: {
"Yes": function() {
alert("a Post to :/Booking.aspx/Cancel/10 would be so nice here instead of the alert");},
"No": function() {$(this).dialog("close");}
},
modal: true,
overlay: {
opacity: 0.5,
background: "black"
}
});
});
以及对话框本身:
<div id="dialog" title="Cancel booking">Are you sure you want to cancel your booking?</div>
最后是我的问题:我怎样才能做到这一点呢?或者有没有更好的方法呢?
https://stackoverflow.com/questions/394491
复制相似问题