intern
intern

Reputation: 225

Script conflict with BundleConfig.cs asp.net mvc

It has been three hours since I've tried to solve the conflict between BundleConfig and a reference to jquery script.

When I discard this

@Scripts.Render("~/bundles/jquery")

My script that use datepicker works correctly but when I need BundleConfig for the life of my app, How can this conflict be avoided?

BundleConfig class:

  public class BundleConfig
{
    // Pour plus d’informations sur le Bundling, accédez à l’adresse http://go.microsoft.com/fwlink/?LinkId=254725 (en anglais)
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui-{version}.js"));

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

        // Utilisez la version de développement de Modernizr pour développer et apprendre. Puis, lorsque vous êtes
        // prêt pour la production, utilisez l’outil de génération sur http://modernizr.com pour sélectionner uniquement les tests dont vous avez besoin.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));
    }

Thank you for your help !

Upvotes: 0

Views: 1014

Answers (1)

wf4
wf4

Reputation: 3827

I'm not entirely certain that I understand your question from the information that you have posted. However, you suggest that when you remove this (@Scripts.Render("~/bundles/jquery")) that your date picker works correctly.:

So I would suggest that if your date picker works when you exclude the jQuery bundle, that you are including it somewhere else also.

Take a look in your _Layout.cshtml file to see if you are referencing another version of jQuery in there, maybe you are also pulling it in from a CDN or something?

If there is nothing in there, get in to your browsers' developer tools and check the console - You can also "view source" on your web page and take a look, maybe do a find on the word "jQuery" to see if its being included more than once.

Upvotes: 1

Related Questions