0

In my MVC Web Application Im loading some scripts in the layout page, so they can be used in every other page that inherits that layout. Since I'm using stuff from Kendo and Foundation I also load their scripts as bundles.

My "head" section in the layout page looks like this:

<head>

<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>@ViewBag.Title | Inquéritos Online Sublime Software</title>
<link rel="shortcut icon" href="~/Content/images/admin-favicon.ico" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="~/Content/css/Site.css" />

@Styles.Render("~/Content/foundation/foundation.css")
@Styles.Render("~/Content/kendo/css")

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/foundation")
@Scripts.Render("~/bundles/kendo");

@RenderSection("head", required: false)
@* Use the Scripts section to define page specific scripts *@
@RenderSection("scripts", required: false)

<!-- Scripts -->
<script type="text/javascript" src="~/Content/scripts/scripts.js"></script>
<script type="text/javascript" src="~/Content/scripts/expand.js"></script>

<script> $(document).foundation(); </script>

</head>

As you may notice I have a semicolon after rendering the Kendo bundle. The strange thing is: If I keep that semicolon, that is not supposed to be there, all my scripts work fine, however I can see the semicolon in the page. In the other hand, if I delete that semicolon, some of my scripts just stop working. Scripts that I define in my views, p.e.

I've been looking around for some time, but I can't figure why this is happening. Any idea?

EDIT:

One of the scripts that stop working:

    $('body').on('click', '.apagar', function () {
        $(this).parents("div.editor-pergunta:first").remove();
        return false;
    });
GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Kevin04PT
  • 9
  • 2
  • 8
  • Can you try to add: System.Web.Optimization.BundleTable.EnableOptimizations = false; in your RegisterBundles method ? (I know that my answer is not directly related to your issue.) – Sebastien Kovacs Aug 06 '14 at 11:43
  • @SebastienKovacs I did that, but it didn't solved the problem. What's the difference in adding that line to the RegisterBundles method? Thanks. – Kevin04PT Aug 06 '14 at 11:56
  • If EnableOptimizations is set to false, Bundling and Minification will be disabled see [link](http://www.codeproject.com/Tips/389545/ASP-NET-MVC-Bundling-and-Minification). Did you have this problem before Disable Optimizations ? – Sebastien Kovacs Aug 06 '14 at 12:14
  • @SebastienKovacs With or without optimization the problem persists. – Kevin04PT Aug 06 '14 at 13:55

0 Answers0