asp mvc:在 jquery 对话框上显示对象详细信息
假设我有一份晚餐清单。该列表将为用户提供位置、数据和一些其他相关信息。
由于有很多人参加,我希望每顿晚餐上都有一个按钮,用于打开一个 jquery 对话框,显示将参加的人。
到目前为止我完成的工作:
在列表上的每顿晚餐上,我都有以下标签
<label class="falselink" id="<%= Html.Encode(item.Id) %>">show attendence</label>
我还有这个脚本,用于在有人单击标签时打开对话框:
<script type="text/javascript">
$(function() {
$('#dialog').dialog({
autoOpen: false,
title: 'Attendence',
modal: true
});
$('.falselink').click(function() {
$('#dialog').dialog('open');
return false;
});
});
</script>
我还有以下包含对话框的 div
<div id="dialog" >
<% Html.RenderAction("DinnerAttendence", new { id = 3 }); %>
</div>
如果我遵循 URL http://localhost/Dinner/DinnerAttendence/3 这有效, 事实上,如果我按下该链接,它会向我显示与参加晚餐的人的对话 3。
我唯一的问题是如何将晚餐 ID 传递给 RenderAction RouteValue?
感谢您的帮助
Suppose I have a list of dinners. This list will present the users with, location, data and some other relevant info.
Since that there's a lot of people attending, I want a button on each dinner that opens a jquery dialog that will show the people that will attend.
What I accomplish until now:
On each dinner on the list I have the following label
<label class="falselink" id="<%= Html.Encode(item.Id) %>">show attendence</label>
I also have this script to open the dialog when someone clicks the label:
<script type="text/javascript">
$(function() {
$('#dialog').dialog({
autoOpen: false,
title: 'Attendence',
modal: true
});
$('.falselink').click(function() {
$('#dialog').dialog('open');
return false;
});
});
</script>
I also have the following div that contains the dialog
<div id="dialog" >
<% Html.RenderAction("DinnerAttendence", new { id = 3 }); %>
</div>
If i follow the URL http://localhost/Dinner/DinnerAttendence/3 this works,
In fact, if I press the link it will show me the dialog with the people attending dinner 3.
My only problem is how i pass the dinner Id to the RenderAction RouteValue?
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这个问题已经很老了,但我还是会回答。
看来这对于 RenderAction 来说是不可能的。
如果您需要从 javascript 获取晚餐 Id,那么您将需要做一些肮脏的事情,例如在对 Url.Action 方法的调用中附加 id:
如果有人知道更好的方法,我很想听听。
I know this question is old but I'll answer anyway.
It appears this is not possible with RenderAction.
If you need to get the dinner Id from javascript then you will need to do something dirty like append the id in a call to the Url.Action method:
If anyone knows of a better way I'd love to hear about it.