我在表格中显示数据,在表格中我有一个链接。如果用户单击该链接,我的目标是打开一个 jquery 对话框,其中将包含要提交的表单。
问题是,如果我点击链接,从第二行向下,它说'jquery is undefined',它没有找到jquery。但是,在第一行,如果我点击链接,它工作正常。
代码:
<script>
var linkObj;
$(function () {
$('#ratingpopup').dialog({
autoOpen: false,
width: 450,
resizable: false,
modal: true,
buttons: {
"Send": function () {
$("#edit-message").html(''); //make sure there is nothing on the message before we continue
$("#updateRatingForm").submit();
},
"Cancel": function () {
$(this).dialog("close");
}
},
title:"Rating/Comment"
});
$("#rating").click(function () {
linkObj = $(this);
var dialogDiv = $('#ratingpopup');
var viewUrl = linkObj.attr('href');
$.get(viewUrl, function (data) {
dialogDiv.html(data);
var $form = $("#updateRatingForm");
$form.unbind();
dialogDiv.dialog('open');
});
return false;
});
});
</script>
<div class="dataTable">
<table>
<tr>
<td>Ordernr.</td>
<td>Dato</td>
<td>Restaurant</td>
<td>Address</td>
<td>Delivery?</td>
<td>Accepted?</td>
<td colspan="3">Action</td>
</tr>
<%foreach (var i in Model)
{ %>
<tr>
<td><%:i.OrderNo %></td>
<td>
<%
DateTime today = DateTime.Now;
DateTime orderDate = Convert.ToDateTime(i.OrderDate);
if (today.Date == orderDate.Date)
{%>
<b> i dag</b>
<%}
else
{ %>
<%:i.OrderDate%>
<%} %></td>
<td><%:i.RestaurantInfo.Name %></td>
<td><%:i.RestaurantInfo.Address %>, <%:i.RestaurantInfo.Postcode %></td>
<td><%:i.IsForDelivery %></td>
<td><%:i.IsAccepted %></td>
<td><a href='<%:Url.Action("Add", "Rating", new { name = i.RestaurantInfo.Name }) %>' id="rating">Rating</a></td> // this is the link
</tr>
<%} %>
</table>
</div>
<div id="ratingpopup"></div>
这对我来说有点奇怪......有人知道这种行为吗?