我有一个剃须刀页面,并以这种方式创建 Kendo 组合控件:
@(Html.Kendo()
.ComboBoxFor(model => model.GenderCode)
.Name("GenderCode")
.Placeholder("Choose Gender...")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(new List<SelectListItem>()
{
new SelectListItem()
{
Text = "Male", Value = "M"
},
new SelectListItem()
{
Text = "Female", Value = "F"
}
})
.Suggest(true))
但它是这样渲染的:
<input data-val="true" data-val-required="Gender Code is required!" id="GenderCode" name="GenderCode" type="text" /><script>
jQuery(function(){jQuery("#GenderCode").kendoDropDownList({"dataSource":[{"Text":"Male","Value":"M"},{"Text":"Female","Value":"F"}],"dataTextField":"Text","dataValueField":"Value"});});
</script>
<span class="field-validation-valid" data-valmsg-for="GenderCode" data-valmsg-replace="true"></span>
有人可以告诉我我做错了什么吗?
更新 在我做了更多调查之后,我看到我收到一个错误“对象[对象对象]没有方法'kendoDatePicker'”,当我在剑道网站上查找时,它是这样说的:
http ://docs.kendoui.com/getting-started/troubleshooting 剑道小部件不可用或未定义的 JavaScript 错误 如果页面中多次包含 jQuery,所有现有的 jQuery 插件(包括剑道 UI)都将被清除。如果未包含所需的 Kendo JavaScript 文件,也会发生这种情况。将抛出以下 JavaScript 错误(取决于浏览器): TypeError: Object # has no method 'kendoGrid' (in Google Chrome) TypeError: $("#Grid").kendoGrid is not a function (in FireFox) Object does '不支持属性或方法'kendoGrid'(在 Internet Explorer 9+ 中)对象不支持此属性或方法(在旧版本的 Internet Explorer 中)
所以我检查了我的包,我没有看到任何地方我将我的 jquery 包含加倍:
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-*"));
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"));
// The Kendo JavaScript bundle
bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
"~/Scripts/kendo/2013.2.716/kendo.web.min.js", // or kendo.all.min.js if you want to use Kendo UI Web and Kendo UI DataViz
"~/Scripts/kendo/2013.2.716/kendo.aspnetmvc.min.js"));
// The Kendo CSS bundle
bundles.Add(new StyleBundle("~/Content/kendo").Include(
"~/Content/kendo/2013.2.716/kendo.common.*",
"~/Content/kendo/2013.2.716/kendo.default.*"));
更新 2 我已经切换并尝试了这个
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-2.0.3.js"));
// The Kendo JavaScript bundle
//bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
// "~/Scripts/kendo/2013.2.716/jquery.min.js"));