0

Developing an ASP.NET MVC 3 application (my first) and running into some trouble with jQuery, as I've never used it before. I'm trying to open up details for a particular search result in a modal dialog.

relevant razor code:

@foreach (var item in Model.claims)
    {
        <tr>
            <td>@Html.ActionLink(item.CLAIMMASTID.Substring(Math.Max(0,item.CLAIMMASTID.Length-1)), "ClaimDetail", new {@id=item.CLAIMMASTID}, new {@class="ClaimsDetail"})</td>
        </tr>
    }

And the controller has that set up to display a partial view:

public ActionResult ClaimDetail()
    {
        return PartialView("_ClaimDetail");
    }

All good so far, yes? That's what I think. So my jQuery script looks as such, and it's where I think the problem lies:

$(function () {
    $('#ClaimsDialog').dialog({
        autoOpen: false,
        width: 800,
        resizable: true,
        modal: true
    });
    $('.ClaimsDetail').live("click", function () {
        var target = $(this).attr('href');
        $.get(target, function (result) {
            ('#ClaimsDialog').html(result);
            ('#ClaimsDialog').dialog({
            });
        });
        return false;
    });
Allison Steranko
  • 237
  • 2
  • 11
  • http://stackoverflow.com/questions/1328723/how-to-generate-a-simple-popup-using-jquery might help – Yasser Shaikh Jul 31 '12 at 13:06
  • Debug the code in VS2010 and see what it says when it reaches the relevant line. Enable debugging in IE (tools->internet options->advanced, uncheck 'disable script debugging'), run the solution and open the web-page in IE. I had to do that today when calling the valid() method did nothing, and turned out I was missing a script reference. Also as DanielB said, live() is deprecated since 1.43 and by default MVC3 uses atleast version 1.5 (1.8 is the jQuery UI version, not jQuery!) – Shahin Dohan Jul 31 '12 at 17:26

1 Answers1

1

replace

 $.get(target, function (result) {
        ('#ClaimsDialog').html(result);
        ('#ClaimsDialog').dialog({
        });
    });

with

  $.get(target, function (result) {
        $('#ClaimsDialog').html(result).dialog('open');
    });
DanielB
  • 19,910
  • 2
  • 44
  • 50