Ashita Shah
Ashita Shah

Reputation: 139

Unable to bundle all 4 scripts in one single bundle

I'am bundling my js files like below

            bundles.Add(new ScriptBundle("~/bundles/important").Include(
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.globalize.js",
             "~/Scripts/jquery-ui-1.12.1.js",
             "~/Scripts/jquery.validate.unobtrusive.min.js"));

'jquery-ui-1.12.1.js' is not loaded. if i just bundle that file separately it gets included. How can i bundle all the 4 scripts in a single bundle?

public class BundleConfig
{
    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/validate").Include(
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.unobtrusive.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/jquery-ui").Include(
      "~/Scripts/jquery-ui-1.12.1.js"));

        BundleTable.EnableOptimizations = true;
    }
}

when I am separately adding like this. it is working properly.

Upvotes: 0

Views: 57

Answers (2)

J88
J88

Reputation: 831

jquery-ui-1.12.1.js needs to be loaded first the other scripts need it.

Upvotes: 0

VIGNESH ARUNACHALAM
VIGNESH ARUNACHALAM

Reputation: 674

Change your BundleConfig as given below.Change the orders of files.

 bundles.Add(new ScriptBundle("~/bundles/jquery").Include(  
        "~/Scripts/jquery-ui-1.12.1.js",  
        "~/Scripts/jquery.validate.unobtrusive.min.js",  
        "~/Scripts/jquery.validate.js",  
        "~/Scripts/jquery.validate.globalize.js"  
        ));  

Upvotes: 1

Related Questions