【问题标题】:Jquery Undefined for Telerik gridTelerik 网格的 Jquery 未定义
【发布时间】:2012-10-08 08:20:13
【问题描述】:

我收到用于 Telerik 网格实现的 javascript 错误“JQuery undefined”,我不明白同样的原因。我确实包含了所有可能的 JQuery 文件,但仍然出现 Javascript 错误。

下面是我实现的示例代码。

<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>

@(Html.Telerik().Grid(Model.Employee)
                                                    .HtmlAttributes(new { style = "width:100%;" })
                                                .Name("Employee")
                                                .DataKeys(keys =>
                                                {
                                                    keys.Add(m => Id);

                                                })

                                                .Columns(columns =>
                                                {

                                                    columns.Bound(p => p.Name).Title("Name")
                                                        .HeaderHtmlAttributes(new { width = "110px", style = "text-align:center;font-weight:bold;height:auto" })
                                                    .HtmlAttributes(new { width = "110px", style = "text-align:left;height:auto" });
                                                    columns.Bound(p => p.ReportedStatus).ClientTemplate("<#= ReportedStatus(data) #>").Title("Reported")
                                                         .HeaderHtmlAttributes(new { width = "130px", style = "text-align:center;font-weight:bold;height:auto" })
                                                    .HtmlAttributes(new { width = "130px", style = "text-align:center;height:auto" });
                                                    columns.Bound(p => p.status).Title("status").ClientTemplate("<#=status(data) #>")
                                                        .HeaderHtmlAttributes(new { width = "130px", style = "text-align:center;font-weight:bold;height:auto" })
                                                    .HtmlAttributes(new { width = "130px", style = "text-align:center;height:auto" });
                                                    columns.Bound(p => p.Hrs).Title("Hrs")
                                                        .HeaderHtmlAttributes(new { width = "150px", style = "text-align:center;font-weight:bold;height:auto" })
                                                    .HtmlAttributes(new { width = "150px", style = "text-align:center;height:auto" });
                                                    columns.Bound(l => l.Location).ClientTemplate("<#= Location(data) #>").Title("Location")
                                                         .HeaderHtmlAttributes(new { width = "200px", style = "text-align:center;font-weight:bold;height:auto" })
                                                    .HtmlAttributes(new { width = "200px", style = "text-align:center;height:auto" });
                                                    columns.Bound(l => l.Role).ClientTemplate("<#= Role(data) #>").Title("Role")
                                                        .HeaderHtmlAttributes(new { width = "150px", style = "text-align:center;font-weight:bold;height:auto" })
                                                    .HtmlAttributes(new { width = "150px", style = "text-align:center;height:auto" });

                                                }).Footer(false)
                                                                          )
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.common.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.textbox.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.grid.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.draganddrop.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.window.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.grid.editing.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.upload.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/telerik.menu.js")"></script>

@(Html.Telerik().ScriptRegistrar()
                 .jQuery(false)
                 .DefaultGroup(group => group
                 .Add("telerik.examples.min.js")
                 .Add("telerik.grid.js")
                 .Compress(false)
                 .Combined(true))
                 .OnDocumentReady(
                 @<text> prettyPrint();
</text>)
)

请让我知道我在这里为这个 JQuery 错误做错了什么。

提前致谢, 马诺伊

【问题讨论】:

  • 请以人们能够阅读的方式缩进您的代码。谢谢。

标签: jquery for-loop telerik grid undefined


【解决方案1】:

看起来您没有正确包含文件。如果您的字符串中有双引号,则解析器会认为它是字符串的结尾并且不能正确解释字符串。您需要转义它们或使用 single Quotes 在里面代替..

代替

src="@Url.Content("~/Scripts/jquery-1.7.1.js")"

试试

src="@Url.Content('~/Scripts/jquery-1.7.1.js')"

         OR
src="@Url.Content(\"~/Scripts/jquery-1.7.1.js\")"

你也可以通过转义双引号来达到同样的效果,因为解析器可能会认为它是位于 " " 之间的字符串的结尾

【讨论】:

  • Sushanth - 我尝试了上述两个选项,但它们都不起作用,并且出现“字符文字中的字符过多”的构建错误。
猜你喜欢
  • 2012-06-25
  • 1970-01-01
  • 2012-06-17
  • 1970-01-01
  • 2013-03-23
  • 2011-10-12
  • 1970-01-01
  • 2012-07-10
  • 1970-01-01
相关资源
最近更新 更多