admin管理员组文章数量:1353186
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>
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.
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>
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.
-
Is your
jqGrid
call withinjQuery
sdocument.ready
function? api.jquery./ready – Chase Commented Mar 17, 2014 at 6:10 - where is trailing section of master page? – Ashwini Verma Commented Mar 17, 2014 at 6:11
1 Answer
Reset to default 5You 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 pleted loading.
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
Hope this helps..
本文标签: aspnetJavaScript runtime error Object doesn39t support property or method 39jqGrid39Stack Overflow
版权声明:本文标题:asp.net - JavaScript runtime error: Object doesn't support property or method 'jqGrid' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743923077a2562454.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论