调试器指示其不起作用

时间:2019-02-16 01:33:06

标签: javascript jquery-ui-dialog

我有两个JavaScript函数。一个我没有传递值,另一个我没有传递值。在Chrome调试器中查看时,出现错误消息,提示该函数无效。

一个好

function CreateEmployee() {
    var div = $("#OpenDilog");
    div.load("/Home/Create", function () {
        div.dialog({
            modal: true,
            width: 500,
            height: 400,
            title: "Add New Employee",
            resizable: false
        });
    });
}

一个坏

function EditEmployee(E_ID) {
    alert("value: " + E_ID);
    var ph = $("#OpenDilog");
    ph.load("/Home/Edit?taskId=" + E_ID, function () {
        ph.dialog({
            modal: true,
            width: 500,
            height: 400,
            resizable: false
        });
    });
}

警告框的确弹出了正确的ID,但随后ph.dialog上的后尾字不起作用。

控制器签名为

[HttpGet]
public PartialViewResult Edit(int taskId)

整个文件

@model List<SFTPWatcherManager.Models.fals_ftp_watcher_manager_sp_Result>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    <style type="text/css">
        .grid {
            width: 100%;
        }
    </style>
}

<div style="padding:7px 0;">
    <input type="button" value="Add New SFTP Watcher" onclick="CreateEmployee()" />

</div>

<div id='OpenDilog'></div>

<h3>Employee Information List</h3>

<div style="width:100%;">
    @{
        WebGrid grid = new WebGrid(Model);
        @grid.GetHtml(
            tableStyle: "grid",
            fillEmptyRows: false,
            mode: WebGridPagerModes.All,
            firstText: "<< First",
            previousText: "< Prev",
            nextText: "Next >",
            lastText: "Last >>",
            columns: new[] {
                grid.Column("task_id",header: "ID"),
                grid.Column("task_name",header: "Name"),
                grid.Column("client"),
                grid.Column(format: @<text><input type="hidden" name="task_id" value="@item.task_id" /> </text>),
                grid.Column("Action", format: @<text><a href="#" , onclick="EditEmployee('@item.task_id');return false;">view</a></text>)
            }
        )
    }

</div>

<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/Scripts/jquery-ui.min.js")


<script type="text/javascript">

    function CreateEmployee() {
        var div = $("#OpenDilog");
        div.load("/Home/Create", function () {
            div.dialog({
                modal: true,
                width: 500,
                height: 400,
                title: "Add New Employee",
                resizable: false
            });
        });
    }

    function EditEmployee(E_ID) {
        alert("value: " + E_ID);
        var ph = $("#OpenDilog");
        ph.load("/Home/Edit?taskId=" + E_ID, function () {
            ph.dialog({
                modal: true,
                width: 500,
                height: 400,
                resizable: false
            });
        });
    }
</script>

0 个答案:

没有答案