我有一個(gè)頁(yè)面使用了Kendoui的combo控件,代碼如下:
@(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>
錯(cuò)誤"Object [object Object] has no method 'kendoDatePicker'"
于是我去查了一下kendo官網(wǎng),它的解釋是這樣的:
JavaScript error that Kendo widgets are unavailable or undefined If jQuery is included
more than once in the page all existing jQuery plugins (including Kendo UI) will be wiped out.
Will also occur if the required Kendo JavaScript files are not included. The following JavaScript
errors will be thrown (depending on the browser): TypeError: Object # has no method 'kendoGrid'
(in Google Chrome) TypeError: $("#Grid").kendoGrid is not a function (in FireFox) Object doesn't
support property or method 'kendoGrid' (in Internet Explorer 9+) Object doesn't support this property
or method (in older versions of Internet Explorer)
然后我檢查我的bundles,但是又沒有發(fā)現(xiàn)哪里多了一個(gè)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 //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.*"));
打破零回復(fù)...
登錄 慧都網(wǎng)發(fā)表評(píng)論