MVC4 - Javascript Not Accessible After NuGet Deploy
I've just performed the first deployment of my MVC application and I've
run into a few problems with the Javascript.
In order to hook things up at run time I do this:
_Layout.cshtml
@if (IsSectionDefined("MyPage"))
{
<script type="text/javascript">
$(document).ready(function () {
@RenderSection("MyPage", required: false)
});
</script>
}
MyPage.cshtml
Then in my Razor views I do this:
@section MyPage
{
myPage.SomeFunction();
}
myPage.js
(function (myPage, $) {
myPage.SomeFunction = function () {
...
};
}(window.myPage= window.myPage|| {}, jQuery));
This is all working great in Debug within VS but as soon as I deploy it
(Continuous Deployment with Otopus Deploy in NuGet packages) I start to
see errors like:
ReferenceError: myPage is not defined.
If I view the source and follow the bundle link the code is there ...
But the file is headed with a Minification error like:
/* Minification failed. Returning unminified contents.
(683,1-2): run-time warning JS1002: Syntax error: }
(683,51-52): run-time warning JS1002: Syntax error: }
*/
// Contains all the javascript required by the myPage page
I'm currently working through the JSLint errors in Visual Studio but I
think these are more about formatting than directly related the
ReferenceError on the JS since the JS is loaded as I can link to the
function from the page source.
Any pointers as to what to look at or how to fix this?
No comments:
Post a Comment