0

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.

Ashita Shah
  • 139
  • 1
  • 11
  • Change order,First you add "jquery-ui-1.12.1.js" then others – VIGNESH ARUNACHALAM Nov 29 '17 at 07:02
  • the client side validations are not working. form gets submitted without validations. @StephenMuecke – Ashita Shah Nov 29 '17 at 07:06
  • You can include as many files as you want. What make you think its not loaded? –  Nov 29 '17 at 07:06
  • `jquery-ui-1.12.1.js` has nothing at all to do with client side validation! The only scripts that are relevant for that are `jquery-{version}.js`, `jquery.validate.js` and `jquery.validate.unobtrusive`. –  Nov 29 '17 at 07:07
  • i want to add the scripts for jquery datepicker and validations in a single bundle. – Ashita Shah Nov 29 '17 at 07:08
  • Are you loading bundle that contain jquery.js first, then need to load this("~/bundles/important") bundle, because it has dependency with jquery – Vaibhav shetty Nov 29 '17 at 07:11
  • What you have shown will do that! If your code is not working then its because your code is wrong (show it) –  Nov 29 '17 at 07:11
  • when i am separately including the jquery-ui in a separate bundle, it is working properly. when added in a single bundle it is not validating. – Ashita Shah Nov 29 '17 at 07:15
  • @Ashita Is all the files at same path. – VIGNESH ARUNACHALAM Nov 29 '17 at 07:18
  • Again, `jquery-ui` has nothing to do with client side validation! It contains scripts for generating the html and the behavior/events for custom controls. –  Nov 29 '17 at 07:21
  • 1
    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" )); – VIGNESH ARUNACHALAM Nov 29 '17 at 07:29
  • @VIGNESHARUNACHALAM, yes it is loading properly now. – Ashita Shah Nov 29 '17 at 07:41

2 Answers2

1

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"  
        ));  
0

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

J88
  • 811
  • 7
  • 20
  • None of the other 3 scripts have anything to do with `jquery-ui-1.12.1.js`! –  Nov 29 '17 at 10:10