So this is my issue:
I have in my MVC 3 project my layout with all my js script included:
<link runat="server" rel="shortcut icon" href="@Url.Content("~/Content/favicone/favicon.ico")" type="image/x-icon"/>
<link runat="server" rel="icon" href="@Url.Content("~/Content/favicone/favicon.ico")" type="image/ico"/>
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.jcarousel.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.dimension.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.cookie.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/globalize.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/cultures/globalize.culture." + CurriculumVitae.Helpers.CultureHelper.GetCurrentCulture() + ".js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.17.custom.min.js")" type="text/javascript"></script>
<script type="text/javascript">
function mycarousel_initCallback(carousel) {....}</script>
But only my default View can used these scripts, when I go in another view(in renderbody) and I need to use some jquery I need to RE-IMPLEMENT the script to make it work:
@{ViewBag.Title = "Index";}
@section header{
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.17.custom.min.js")" type="text/javascript"></script>
<script>
$.fx.speeds._default = 1000;
$(function () {
$("#dialog").dialog({
autoOpen: true,
show: "blind",
hide: "explode"
});
$("#opener").click(function () {
$("#dialog").dialog("open");
return false;
});
});
</script>
}
<a id="opener" href="javascript:void();">test </a>
<div id="dialog" title="Basic modal dialog">
<p>terst nmsdfnms dfds fsd f JQUERYYYYYYYYYYYYYY</p>
</div>
And this is just the beginning … I have other issue with my Theme/Culture..
The thing is in the source code of my web page, I found all the scripts from the _layout (and the “view”) but without the @section header, even a simple js call would not work if it has to used a script from my header(_layout)
thank you
I found my problem:
Never re-implement or overide jquery-1.7.1.min.js within the same web
page as it will create a conflict between each jquery call.
One of my scripts using (jcarousel.js) was not correctly setup (the
initCallback param).
Thank you everyone 😉