Telerik和ASP.NET MVC4运行时错误:无法获取属性' jQuery'未定义的

时间:2015-02-04 14:20:01

标签: asp.net-mvc-4 telerik

我想绑定到一个名为scheduler的控制器,但是我得到一个例外,如下所示 0x800a138f - JavaScript运行时错误:无法获取未定义的属性“jQuery”
来自kendo.scheduler.min.js

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_MasterLayout.cshtml";
}
<div id="team-schedule">
    <div id="people">
        <input checked type="checkbox" id="alex" value="1">
        <input checked type="checkbox" id="bob" value="2">
        <input type="checkbox" id="charlie" value="3">
    </div>
</div>

@(Html.Kendo().Scheduler<HHAM.Models.TaskViewModel>()

    .Name("scheduler")
    .Date(new DateTime(2013, 6, 13))
    .StartTime(new DateTime(2013, 6, 13, 7, 00, 00))
    .Height(600)
    .Views(views =>
    {
        views.DayView();
        views.WorkWeekView(workWeekView => workWeekView.Selected(true));
        views.WeekView();
        views.MonthView();
        views.AgendaView();
        views.TimelineView();
    })
    .Timezone("Etc/UTC")
    .Resources(resource =>
    {
        resource.Add(m => m.OwnerID)
                   .Title("Owner")
                   .DataTextField("Text")
                   .DataValueField("Value")
                   .DataColorField("Color")
                   .BindTo(new[] {
                new { Text = "Alex", Value = 1, Color = "#f8a398" } ,
                new { Text = "Bob", Value = 2, Color = "#51a0ed" } ,
                new { Text = "Charlie", Value = 3, Color = "#56ca85" }
            });
    })
    .DataSource(d => d
        .Model(m =>
        {
            m.Id(f => f.TaskID);
            m.Field(f => f.Title).DefaultValue("No title");
            m.Field(f => f.OwnerID).DefaultValue(1);
            m.Field(f => f.Title).DefaultValue("No title");
        })
        .Read("Read", "Scheduler")
        .Create("Create", "Scheduler")
        .Destroy("Destroy", "Scheduler")
        .Update("Update", "Scheduler")
        .Filter(filters =>
        {
            filters.Add(model => model.OwnerID).IsEqualTo(1).Or().IsEqualTo(2);
        })
    )
)
<script type="text/javascript">
    $(function () {
        $("#people :checkbox").change(function (e) {
            var checked = $.map($("#people :checked"), function (checkbox) {
                return parseInt($(checkbox).val());
            });

            var filter = {
                logic: "or",
                filters: $.map(checked, function (value) {
                    return {
                        operator: "eq",
                        field: "OwnerID",
                        value: value
                    };
                })
            };

            var scheduler = $("#scheduler").data("kendoScheduler");

            scheduler.dataSource.filter(filter);
        });
    })
</script>
<style scoped>
    #scheduler {
        font-size: 14px;
    }
    #team-schedule {
        background: url('@Url.Content("~/Content/web/scheduler/")team-schedule.png') transparent no-repeat;
        height: 115px;
        position: relative;
    }

    #people {
        background: url('@Url.Content("~/Content/web/scheduler/")scheduler-people.png') no-repeat;
        width: 345px;
        height: 115px;
        position: absolute;
        right: 0;
    }
    #alex {
        position: absolute;
        left: 4px;
        top: 81px;
    }
    #bob {
        position: absolute;
        left: 119px;
        top: 81px;
    }
    #charlie {
        position: absolute;
        left: 234px;
        top: 81px;
    }
</style>

/////////////////////////////////////////////// //////

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui-{version}.js"));



        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        // to implement the Telerik you have to add Kendo scripts // Mona 1/25/2015
        bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
            "~/Scripts/kendo/kendo.scheduler.min.js",
              "~/Scripts/kendo/kendo.timezones.min.js",
             "~/Scripts/kendo/kendo.aspnetmvc.min.js"
            ));
        //////////////////////////////////////////////////////////////////

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));


        bundles.Add(new StyleBundle("~/Content/kendo/css").Include(
                 "~/Content/kendo/kendo.common-bootstrap.min.css",
                 "~/Content/kendo/kendo.bootstrap.min.css"));

        bundles.IgnoreList.Clear();
    }
}

}

//////////////// layout /////////////////

@{
    var Roles = ViewBag.Roles as List<string>;
    var allUserTasks = ViewBag.Tasks as List<HHAM.Business.menuModel>;
    var uname = ViewBag.username;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="@ViewBag.MetaDesc" />
    <meta name="author" content="CStride,LLC" />
    <meta http-equiv="refresh" content="62;">
    <title>@ViewBag.Title || HomeHealth || CStride,LLC</title>

    @Styles.Render("~/Content/kendo/css")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/kendo")

    <link rel="stylesheet" href="~/Content/themes/neon/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css">
    <link rel="stylesheet" href="~/Content/themes/neon/css/font-icons/entypo/css/entypo.css">
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Noto+Sans:400,700,400italic">
    <link rel="stylesheet" href="~/Content/themes/neon/css/bootstrap.css">
    <link rel="stylesheet" href="~/Content/themes/neon/css/neon-core.css">
    <link rel="stylesheet" href="~/Content/themes/neon/css/neon-theme.css">
    <link rel="stylesheet" href="~/Content/themes/neon/css/neon-forms.css">
    <link rel="stylesheet" href="~/Content/themes/neon/css/custom.css">
    <link rel="stylesheet" href="~/Content/themes/neon/css/skins/blue.css">

    <script src="~/Content/themes/neon/js/jquery-1.11.0.min.js"></script>

    <!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body class="page-body  page-fade-only">

    <div class="page-container">
        <!-- add class "sidebar-collapsed" to close sidebar by default, "chat-visible" to make chat appear always -->

        <div class="sidebar-menu">
            @Html.Partial("_MasterHeaderLayout")

            @Html.Partial("_MasterMenuLayout")
        </div>
        <div class="main-content">

            <div class="row">

                <!-- Profile Info and Notifications -->
                <div class="col-md-6 col-sm-8 clearfix">

                    <ul class="user-info pull-left pull-none-xsm">

                        <!-- Profile Info -->
                        <li class="profile-info dropdown">
                            <!-- add class "pull-right" if you want to place this from right -->

                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <img class="img-circle" width="44" alt="" src="~/Content/themes/neon/images/thumb-1@2x.png">
                                @uname

                            </a>

                            <ul class="dropdown-menu">

                                <!-- Reverse Caret -->
                                <li class="caret"></li>

                                <!-- Profile sub-links -->

                                <li>
                                    <a href="@Url.Action("Inbox", "Mail")">
                                        <i class="entypo-mail"></i>
                                        Inbox
                                    </a>
                                </li>

                                <li>
                                    <a href="@Url.Action("CaseManagerTasks", "Dummy")">
                                        <i class="entypo-calendar"></i>
                                        Calendar
                                    </a>
                                </li>

                                <li>
                                    <a href="@Url.Action("MyTasks", "Dummy")">
                                        <i class="entypo-clipboard"></i>
                                        Tasks
                                    </a>
                                </li>
                            </ul>
                        </li>
                    </ul>

                    <ul class="user-info pull-left pull-right-xs pull-none-xsm">
                        <li class="notifications dropdown">

                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
                                <i class="entypo-plus-squared"></i>
                                <span class="badge badge-info">New</span>
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <ul class="dropdown-menu-list scroller">
                                        <li>
                                            <a href="#">
                                                Order
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                Communication
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                PRN Visit
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                Patient
                                            </a>
                                        </li>
                                        <li>
                                            <p class="text-muted">
                                                Authorization
                                            </p>
                                        </li>
                                        <li>
                                            <p class="text-muted">
                                                Episode
                                            </p>
                                        </li>
                                        <li>
                                            <a href="#">
                                                Hospital
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                Physician
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                External Referral
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                Insurance
                                            </a>
                                        </li>
                                        @if (User.IsInRole("SystemAdim") || User.IsInRole("SystemOwner")) {
                                        <li>
                                            <a href="@Url.Action("NewUser", "Dummy")">
                                                User
                                            </a>
                                        </li>
                                        }
                                    </ul>
                                </li>
                            </ul>
                        </li>

                        <li class="notifications dropdown">

                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
                                <i class="entypo-eye"></i>
                                <span class="badge badge-info">View</span>
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <ul class="dropdown-menu-list scroller">
                                        <li>
                                            <a href="#">
                                                Clinica Operations
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                Therapy
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                Administration
                                            </a>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>


                <!-- Raw Links -->
                <div class="col-md-6 col-sm-4 clearfix hidden-xs">

                    <ul class="list-inline links-list pull-right">
                        <li>
                            @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
                            {
                                @Html.AntiForgeryToken()
                                <a href="javascript:document.getElementById('logoutForm').submit()">
                                    Log Out <i class="entypo-logout right"></i>
                                </a>
                            }
                        </li>
                    </ul>

                </div>
            </div>
            <hr />
            @RenderBody()
            <footer class="main">
                &copy; @DateTime.Now.Year <strong>HomeHealth System</strong> by CStride,LLC
            </footer>
        </div>

        <link rel="stylesheet" href="~/Content/themes/neon/js/jvectormap/jquery-jvectormap-1.2.2.css">
        <link rel="stylesheet" href="~/Content/themes/neon/js/rickshaw/rickshaw.min.css">

        <!-- Bottom Scripts -->
        <script src="~/Content/themes/neon/js/gsap/main-gsap.js"></script>
        <script src="~/Content/themes/neon/js/jquery-ui/js/jquery-ui-1.10.3.minimal.min.js"></script>
        <script src="~/Content/themes/neon/js/bootstrap.js"></script>
        <script src="~/Content/themes/neon/js/joinable.js"></script>
        <script src="~/Content/themes/neon/js/resizeable.js"></script>
        <script src="~/Content/themes/neon/js/neon-api.js"></script>
        <script src="~/Content/themes/neon/js/jquery.dataTables.min.js"></script>
        <script src="~/Content/themes/neon/js/datatables/TableTools.min.js"></script>
        <script src="~/Content/themes/neon/js/dataTables.bootstrap.js"></script>
        <script src="~/Content/themes/neon/js/datatables/jquery.dataTables.columnFilter.js"></script>
        <script src="~/Content/themes/neon/js/datatables/lodash.min.js"></script>
        <script src="~/Content/themes/neon/js/datatables/responsive/js/datatables.responsive.js"></script>
        <script src="~/Content/themes/neon/js/select2/select2.min.js"></script>
        <script src="~/Content/themes/neon/js/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
        <script src="~/Content/themes/neon/js/jvectormap/jquery-jvectormap-europe-merc-en.js"></script>
        <script src="~/Content/themes/neon/js/jquery.sparkline.min.js"></script>
        <script src="~/Content/themes/neon/js/rickshaw/vendor/d3.v3.js"></script>
        <script src="~/Content/themes/neon/js/rickshaw/rickshaw.min.js"></script>
        <script src="~/Content/themes/neon/js/raphael-min.js"></script>
        <script src="~/Content/themes/neon/js/morris.min.js"></script>
        <script src="~/Content/themes/neon/js/toastr.js"></script>
        <script src="~/Content/themes/neon/js/neon-chat.js"></script>
        <script src="~/Content/themes/neon/js/neon-custom.js"></script>
        <script src="~/Content/themes/neon/js/neon-demo.js"></script>


        @RenderSection("scripts", required: false)
        </div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您使用的是哪种版本的Telerik UI?请确认您没有2013年第二季度,或更新到最新版本。 http://www.telerik.com/forums/q2%2713-release---unable-to-get-property-jquery-of-undefined-or-null-reference-invalid-regular-expressions-or-expected-js-errors

另外,检查并确保在Kendo脚本之前加载jQuery脚本。我注意到你正确配置了捆绑包但有时候.Net的捆绑包并没有添加缩小的脚本。确保~/Scripts/jquery-{version}.js下的文件没有缩小,如果是,请尝试添加标准版本。