I am using @Darin Dimitrov's method explained in Loading a partial view in jquery.dialog to allow users to click on one of their Private Messages and view it inside a modal box. I am using ASP.NET MVC3 and Razor as my view engine. But I'm having some trouble getting this to work... Below is what I've attempted so far:
The messages are displayed in a table:
<tr id="@item.Id" class="openConversationLink">
<td class="newMessageStatus">@MessageStatus(item)</td>
<td class="msgSenderName">@item.Sender</td>
<td class="msgSubject">@item.Subject</td>
<td class="msgLastUpdated">@item.LastUpdated</td>
<td class="modalItemActions"></td>
</tr>
And inside the same partial view, I got the following script block:
<script type="text/javascript">
$(function () {
$("#conversationModal").dialog({
autoOpen: false,
width: 850,
height: 600,
resizable: false,
draggable: false,
modal: true,
open: function (event, ui) {
var convId = ui.attr('id');
alert(convId);
$(this).load('@Url.Action("Conversation", "Message", new { conversationId = convId})');
}
});
$(".openConversationLink").click(function () {
$("#conversationModal").dialog('open');
});
});
</script>
Basically, I'm not sure what the event
and ui
parameters inside the open
handler refer to. So a little explanation on both would be appreciated. But anyway, even the messages do not get displayed now, I keep getting those error:
Compiler Error Message: CS0103: The name "convId" does not exist in the current context. Source: $(this).load('@Url.Action("Conversation", "Message", new { conversationId = convId})');
Basically, I do not want that line to get triggered until I actually click on one of the rows (to open the conversation dialog), but it seems like it's actually getting triggered when the Messages page opens.
UPDATE:
Here's my jQuery code now:
$(function () {
$("#conversationModal").dialog({
autoOpen: false,
width: 850,
height: 600,
resizable: false,
draggable: false,
modal: true,
open: function (event, ui) {
var convId = event.target.attr('id');
alert(convId);
$(this).load('Message/Conversation/' + convId);
}
});
$(".openConversationLink").click(function () {
$("#conversationModal").dialog('open');
});
});
Anything that can be done about that? :)