So I am trying to convert my plain HTML/Javascript site (which works fine) into an ASP MVC4 project. What I do is get and XML and use and XSLT to transform. I litreally use the code from here to do that
In my _Layout.cshtml
I use razor to load the resource
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
... things...
@Scripts.Render("~/bundles/kendoScripts")
@Scripts.Render("~/bundles/customScript")
@Styles.Render("~/Content/themes/Kendo")
@Styles.Render("~/Content/themes/customCSS")
my view that uses the layout is very straight forward, this is all that is in the page
@using Summ.ExtensionCode
@model SumMVC.Models.SummaryModel
@{
ViewBag.Title = "_Summary";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div data-role="content">
@Html.RenderXml(Model.ProgramFilename, Model.StylesheetFilename, Model.Parameters)
</div>
In @Scripts.Render("~/bundles/customScript")
, is a JS file, renderpage.js that has this bit of code $(this).kendoDropDownList();
where this is a select element. But I am getting a error that .kendoDropDownList();
is not a function. The error from firebug: TypeError: $(...).kendoDropDownList is not a function
and the errror from GoogleChrome Uncaught TypeError: Object [object Object] has no method 'kendoDropDownList'
. It seems that in my bundle the JS file kendo.all.min.js is not begin loaded here is what is looks like
bundles.Add(new ScriptBundle("~/bundles/kendoScripts")
.Include("~/Scripts/kendoui/kendo.web.min.js")
.Include("~/Scripts/kendoui/kendo.all.min.js")
);
....
bundles.Add(new ScriptBundle("~/bundles/customScript")
.....
.Include("~/Scripts/SummaryScript/renderpage.js")
....
);
I am assuming that perhaps the code is being executed before kendo.all.min.js is done loading, but as you can see above renderpage.js is after kendo. Any ideas or insight?
UPDATE
I forgot to add that when I manually load the resource in the MVC project in the head tag
<script type="text/javascript" src="~/Scripts/kendoui/kendo.web.min.js"></script>
<script type="text/javascript" src="~/Scripts/kendoui/kendo.all.min.js"></script>
....
<script type="text/javascript" src="~/Scripts/ExecSummaryScript/renderpage.js"></script>
it works fine.
Update2
Turns out the Kendo JS file is not being loaded at all. I check the resource in the dev console and notice that it not even there.Upon closer inspection I notice that all resources are loaded except some .min.js
files. There are a few loaded but some that are not loaded are jquery-ui-1.10.3.min.js, and jquery.browser.min.js.
I knew it was going to be something stupid. Turns out that it's a MVC4 gothcha. I had to rename my file. Appearently it did not like files with extension min.js
I found the answer here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With