1

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

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
dcarneiro
  • 7,060
  • 11
  • 51
  • 74

1 Answers1

0

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:

     $.get('@(Url.Action("DinnerAttendence", "Dinners"))/' + dinnerId, 
function (data) { $("#dialog").append(data); });

If anyone knows of a better way I'd love to hear about it.

nicodenzl
  • 121
  • 8