【问题标题】:Get jQuery dialog to work onlcik让 jQuery 对话框在点击时工作
【发布时间】:2013-01-17 21:49:30
【问题描述】:

我试图有一个图标,当单击时,触发一个 jQuery 对话框,显示特定于被单击项目的消息。由于我是 jQuery 新手,我绝对没有运气。有人可以告诉我我做错了什么吗?

ASP MVC 视图中的代码部分

    <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 代码:

<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>

编辑

onlick 方法名称之前包含错误。有一个额外的')'。

【问题讨论】:

    标签: jquery asp.net-mvc dialog


    【解决方案1】:

    你在这个GetNotes 函数中有一些非常糟糕的javascript。试试这样:

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

    还要在浏览器中查看您的 javascript 调试控制台。它会显示错误。

    【讨论】:

    • 谢谢!我也有一个错字 onlick 电话。有一个额外的')'
    • 是的,一开始没有注意到。查看 js 控制台。它会告诉你一切。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多