JavaScript的运行时错误:对象不支持属性或方法“的jqGrid” [英] JavaScript runtime error: Object doesn't support property or method 'jqGrid'

查看:1837
本文介绍了JavaScript的运行时错误:对象不支持属性或方法“的jqGrid”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的异常 - 的JavaScript运行时错误:对象不支持属性或方法的jqGrid'当我下面块移动从内容页的日程地址搜索Maincontent到标题母版页的部分。

I get the exception - "JavaScript runtime error: Object doesn't support property or method 'jqGrid'" when I move below block from maincontent of content page to header section of master page.

<link href="../Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />
<link href="../Content/jquery.jqGrid/jquery-ui-custom.css" rel="stylesheet" />
<script src="../Scripts/jquery-1.9.1.min.js"></script>
<script src="../Scripts/jquery.jqGrid.js"></script>
<script src="../Scripts/i18n/grid.locale-en.js"></script>


这只有当我把这个块尾随母版页的部分作品。

可能有人帮助我理解为什么它的工作原理,只有当我把这个块尾随母版页的部分,但不是在标题部分?
我觉得这是与装载依赖和jqGrid的初始化,但是我需要具体的了解。

It only works when I place this block in trailing section of master page.
Could someone help me understand why it works only when I place this block in trailing section of master page but not in header section? I think this has something to do with loading dependencies and initialization of jqGrid, however I need concrete understanding.

推荐答案

您必须等待,直到 DOM完成加载。那么你可以申请你的脚本。因为,在你的母版页,您正在使用的脚本的底部,因为解析器使用自上而下的办法,它执行脚本,机身装载完成后。

You have to wait until DOM finishes loading. Then you can apply your scripts. Since, in your master page, you are using the script at the bottom, since the parser uses top down approach, it executes the script, after the body is completed loading.

所以,如果你想放于头部,确保所有你的脚本里面的document.ready()函数

So, if you do want to put in head section, ensure that all your script is inside document.ready() function

此外,要知道,它始终是一个最佳实践把所有的脚本在,而不是在头文件

Also , know that it is always a best practice to put all your scripts at bottom rather than at the header.

这是一个良好的性能指标即可。此外,它避免的使用就绪函数

This is a good performance indicator. Also it avoids the usage of ready function

希望这有助于..

这篇关于JavaScript的运行时错误:对象不支持属性或方法“的jqGrid”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆