Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello


I am using a template i bought from themeforest in my mvc 5 application, everthing is working fine except whenever i want to include some external javascript files that didnt come with the template, then the javascript would not see the javascript that came with the template anymore! below is my code:

BundleConfig.cs:
C#
public static void RegisterBundles(BundleCollection bundles)
    {

        bundles.Add(new ScriptBundle("~/bundles/Javascript",
                       @"//code.jquery.com/jquery-1.10.2.js"
                       ).Include(
                        "~/Scripts/jquery-{version}.js"));
        bundles.Add(new ScriptBundle("~/bundles/Javascript",
                       @"//code.jquery.com/ui/1.11.4/jquery-ui.js"
                       ).Include(
                        "~/Scripts/jquery-{version}.js"));
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"));
        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
            "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new StyleBundle("~/Content/jqueryui").Include(
            "~/Content/themes/base/all.css"));          

        bundles.Add(new ScriptBundle("~/bundles/Javascript").Include(
            "~/DataTables-1.10.10/media/js/jquery.js",
            "~//code.jquery.com/jquery-1.10.2.js",
            "~/DataTables-1.10.10/media/js/jquery.js",
            "~/DataTables-1.10.10/media/js/jquery.dataTables.js"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
            "~/Content/themes/base/accordion.css",
            "~/Content/themes/base/all.css",               
            "~/Content/themes/base/base.css",                
            "~/Content/themes/base/datepicker.css",
            "~/Content/themes/base/dialog.css",               
            "~/Content/themes/base/tabs.css",               
            "~/Content/themes/base/tooltip.css"));

        BundleTable.EnableOptimizations = true;
        bundles.UseCdn = true;
    }


_Layout.schtml:

HTML
<pre lang="HTML">
<head>
    <title>Farm Management System</title>
    <!-- start: META -->
    <meta charset="utf-8" />
    <!--[if IE]><meta http-equiv='X-UA-Compatible' content="IE=edge,IE=9,IE=8,chrome=1" /><![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <!-- end: META -->


    @Styles.Render("~/Content/css")
   @Styles.Render("~/Content/jqueryui")
    @Styles.Render("~/Content/themes/base/css")




    @Scripts.Render("~/bundles/jquery")
   @Scripts.Render("~/bundles/bootstrap")
    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/JavaScript")
    @Scripts.Render("~/bundles/modernizr")

    <script type="text/javascript">
        $(function() {
            $(".jqueryui-marker-datepicker").datepicker({
                dateFormat: "dd/mm/yy",
                changeYear: true,
                showOn: "button"
            }).css("display", "inline-block")
                .next("button").button({
                    icons: { primary: "ui-icon-calendar" },
                    label: "Select a date",
                    text: false
                });
        });
    </script>



    @RenderSection("Scripts", required : false)



    <!-- start: MAIN CSS -->

    <link rel="stylesheet" href="~/assets/plugins/bootstrap/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/plugins/font-awesome/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/fonts/style.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/css/main.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/css/main-responsive.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/plugins/iCheck/skins/all.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/plugins/bootstrap-colorpalette/css/bootstrap-colorpalette.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/plugins/perfect-scrollbar/src/perfect-scrollbar.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/css/theme_light.css" type="text/css" id="skin_color"/>
    <link rel="stylesheet" href="~/assets/css/print.css" type="text/css" media="print" />



    <!--[if IE 7]>
        <link rel="stylesheet" href="~/assets/plugins/font-awesome/css/font-awesome-ie7.min.css">
    <![endif]-->
    <!-- end: MAIN CSS -->

    <link rel="shortcut icon" href="favicon.ico" />


    <!-- start: MAIN JAVASCRIPTS -->
    <!--[if lt IE 9]>
        <script src="~/assets/plugins/respond.min.js"></script>
        <script src="~/assets/plugins/excanvas.min.js"></script>
        <script type="text/javascript" src="~/assets/plugins/jQuery-lib/1.10.2/jquery.min.js"></script>
    <![endif]-->
    <!--[if gte IE 9]><!-->
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/jQuery-lib/2.0.3/jquery.min.js")"></script>
    <!--<![endif]-->
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/jquery-ui/jquery-ui-1.10.2.custom.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/bootstrap/js/bootstrap.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/blockUI/jquery.blockUI.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/iCheck/jquery.icheck.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/perfect-scrollbar/src/jquery.mousewheel.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/perfect-scrollbar/src/perfect-scrollbar.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/less/less-1.5.0.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/jquery-cookie/jquery.cookie.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/plugins/bootstrap-colorpalette/js/bootstrap-colorpalette.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/assets/js/main.js")"></script>


    <!-- end: MAIN JAVASCRIPTS -->

    <script>
        jQuery(document).ready(function () {
            Main.init();
            Index.init();
            FormElements.init();
            FormValidator.init();
            UIButtons.init();
            //TableData.init();
        });
    </script>


    @RenderSection("CSS", required : false)
    @RenderSection("JavaScript", required : false)



</head>


Content.cshtml:

JavaScript
@section JavaScript
{
    <!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <script>
        $(function () {
            $("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
            $("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left");
        });
    </script>
    <!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
}

@section CSS
     {
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes /smoothness/jquery-ui.css">
}



Now on this page, the side menu and menu bar items from _Layout Page no longer working, please, i will appreciate if anyone could show me how to do it right. Thanks
Posted
Comments
Uwakpeter 13-Nov-15 7:36am    
I have this on the content page:

@section JavaScript
{
<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function () {
$("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
$("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left");
});
</script>
<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
}

@section CSS
{
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes /smoothness/jquery-ui.css">
}

1 solution

Any external script files go on the page as normal <script> tags, you only bundle the files that are on your own server.
 
Share this answer
 
v2
Comments
Uwakpeter 13-Nov-15 9:48am    
i have tried that still not working!
F-ES Sitecore 13-Nov-15 10:03am    
Then you're doing it wrong, maybe adding the CDN libraries after your bundling when they need to go before. Update your original question with the relevant code, we can't access your system.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900