NealR
NealR

Reputation: 10669

Get jQuery dialog to work onlcik

I am trying to have an icon, when clicked, trigger a jQuery dialog box that displays message specific to the item being clicked. Since I'm new to jQuery, I'm having absolutely no luck. Can someone please tell me what I'm doing wrong?

Section of code from the ASP MVC View

    <td>
    @if (!String.IsNullOrWhiteSpace(item.Notes))
    {
        <span id="notes" onclick='GetNotes(@id);'>
            <img src="@Url.Content("~/Content/images/magnify.gif")" alt="Show Notes" />
        </span>           
    }

        <div id="@id" style="display:none;">
            @Html.DisplayFor(modelItem => item.Notes)
        </div>       
    </td>

jQuery code:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script src="@Url.Content("~/Scripts/jquery.tablesorter.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#thetable").tablesorter();
    }
    );

    function GetNotes(id) {
        $(function GetNotes() {
            $("#" + id + "\"").dialog();
        });
    }

</script>

EDIT

the onlick method name contained an error previously. There was an extra ')'.

Upvotes: 2

Views: 70

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

You have some pretty broken javascript within this GetNotes function. Try like this:

function GetNotes(id) {
    $('#' + id).dialog();
}

Also watch your javascript debugging console in the browser. It will show you the errors.

Upvotes: 2

Related Questions