7

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.

Community
  • 1
  • 1
Jack Thor
  • 1,554
  • 4
  • 24
  • 53
  • This means the jquery plugin "kendoDropDownList" is not included, or was included on a different version of jquery than what is currently represented by `$` – Kevin B Jan 03 '14 at 21:13
  • @KevinB That's what I though too. So what I did was replace jquery 1.8 with 1.9 no luck there, and also tries jqueryMigrate from https://github.com/jquery/jquery-migrate/ nothing there too. I should note that I included everything from the HTML/Javascript project and it all works fine just not in the MVC project – Jack Thor Jan 03 '14 at 21:25
  • the version of jquery is irrelevant, what's important is where jquery is included on the page relative to kendoui – Kevin B Jan 03 '14 at 21:27
  • @KevinB Yeah seems that the Kendoui comes package with jquery. As said in the answer to this post http://stackoverflow.com/questions/14382884/issues-with-kendoui-and-jquery-1-9-0 Also I do see a jquery.min.js inside the kendoui folder that I got. – Jack Thor Jan 03 '14 at 21:30
  • @KevinB 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. – Jack Thor Jan 04 '14 at 00:08

1 Answers1

2

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

Community
  • 1
  • 1
Jack Thor
  • 1,554
  • 4
  • 24
  • 53