Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有剑道网格事件的外部Javascript文件_Javascript_Asp.net Mvc 4_Kendo Ui_Kendo Grid_Jquery Events - Fatal编程技术网

具有剑道网格事件的外部Javascript文件

具有剑道网格事件的外部Javascript文件,javascript,asp.net-mvc-4,kendo-ui,kendo-grid,jquery-events,Javascript,Asp.net Mvc 4,Kendo Ui,Kendo Grid,Jquery Events,是否有从外部Javascript文件读取剑道事件的正确方法 在我看来,.cshtml @(Html.Kendo().Grid<Model>() .Name("EmployeeGrid") .Columns(cols => { }) .Events(evt => evt.DataBound("afterGridLoaded")) .DataSource(dataSourc

是否有从外部Javascript文件读取剑道事件的正确方法

在我看来,.cshtml

@(Html.Kendo().Grid<Model>()
        .Name("EmployeeGrid")
        .Columns(cols => { })
        .Events(evt => evt.DataBound("afterGridLoaded"))
        .DataSource(dataSource => dataSource.Ajax()
                                    .Batch(true)
                                    .PageSize(10)
                                    .Read(read => read.Action("GetEmployeeList", "EmployeeDetail"))
                                   )
      )
以及Javascript的调用方式——这是在页面顶部完成的

@section scripts
{
    <script src="~/Scripts/Views/EmployeeDetail/EmployeeList.js" ></script>    
}
@节脚本
{
}
外部Javascript文件已加载,正如我在Chrome中的开发工具的网络选项卡下看到的那样

当我尝试加载页面时,控制台上会出现以下错误消息,阻止页面进一步加载


有没有办法使用外部Javascript文件使剑道事件正常工作?

问题在于
afterGridLoaded
函数围绕着
jQuery
闭包函数,这意味着不能从闭包外部调用它

移除闭包并将脚本标记移动到页面底部

// $(function () { get rid of this
function afterGridLoaded(e) {
    $(".k-button.xxx").click(function () {
        debugger;
        var idEmployee = $(this).attr('tag');
        myJsFunc(idEmployee);
    });
}
//}); and this

问题是您的
afterGridLoaded
函数围绕着
jQuery
闭包函数,这意味着您不能从闭包外部调用它

移除闭包并将脚本标记移动到页面底部

// $(function () { get rid of this
function afterGridLoaded(e) {
    $(".k-button.xxx").click(function () {
        debugger;
        var idEmployee = $(this).attr('tag');
        myJsFunc(idEmployee);
    });
}
//}); and this

问题是您的
afterGridLoaded
函数围绕着
jQuery
闭包函数,这意味着您不能从闭包外部调用它

移除闭包并将脚本标记移动到页面底部

// $(function () { get rid of this
function afterGridLoaded(e) {
    $(".k-button.xxx").click(function () {
        debugger;
        var idEmployee = $(this).attr('tag');
        myJsFunc(idEmployee);
    });
}
//}); and this

问题是您的
afterGridLoaded
函数围绕着
jQuery
闭包函数,这意味着您不能从闭包外部调用它

移除闭包并将脚本标记移动到页面底部

// $(function () { get rid of this
function afterGridLoaded(e) {
    $(".k-button.xxx").click(function () {
        debugger;
        var idEmployee = $(this).attr('tag');
        myJsFunc(idEmployee);
    });
}
//}); and this