0

I am creating an application on ASP.NET MVC4.

I am displaying the data in jqGrid, which has a hyperlink attached with the name column.

On click of it, a jQuery dialog box is opened.

Same thing doesnot work when I deploy the application.

I get a error message:

TypeError: n.browser is undefined

with error showing on:

<script src="/Analytics/bundles/jqueryui?v=a0vNGd5I0ua6k0Tl4zU-HRoN0y8crNJXKefaMq_937w1">

I tried finding the solution on Internet but didn't find a clue. I've checked that all js and css are loading only once.

Here is the screenshot: Html from Firebug

BundleConfiguration is also set true.

Need a solution...

Update for @Amila's request: BundleConfig.cs

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

    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.all.css",
                "~/Content/themes/base/jquery.ui.theme.css"));

    bundles.Add(new StyleBundle("~/Content/jquery.jqGrid/css").Include("~/Content/jquery.jqGrid/ui.jqgrid.css"));
}

_Layout.cshtml

(Head code)

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Styles.Render("~/Content/jquery.jqGrid/css")
@Styles.Render("~/Content/themes/base/css")

(Body code)

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@RenderSection("scripts", required: false)

View of JQGrid contains:

@section Scripts{
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/Scripts/i18n/grid.locale-en.js")
    @Scripts.Render("~/Scripts/jquery.jqGrid.min.js")
}
vipul_surana
  • 114
  • 2
  • 5
  • 21
  • as you are using "~/Scripts/jquery-{version}.js" it will take what ever the jQuery version in your Script folder. is it the same version you use in your localhost and in your server? – Amila Sep 04 '14 at 07:34
  • Sorry for incomplete information. I'm using jquery-2.1.0 and jquery-ui-1.10.4. And I'm using the same versions in localhost and IIS, the same code is getting published and deployed on IIS – vipul_surana Sep 04 '14 at 07:35
  • 1
    try including `` just after `@Scripts.Render("~/bundles/jquery")` – Amila Sep 04 '14 at 07:41
  • 1
    use this as a temporary solution as its meant to use when upgrading from older versions of jQuery (before 1.9 to 1.9 or later). Has to dig more to find the real problem. From what you have said you are using a jQuery Ui version that is supported jQuery 1.6+, but not sure if it supports jQuery 2+. they have a new version of jQuery ui (1.11). Please try with it and remove migration plugin – Amila Sep 04 '14 at 08:44
  • We have upgradation day on Friday, I'll work on it and let you know. Thanks again. – vipul_surana Sep 04 '14 at 08:56

5 Answers5

1

Hey you have to use the latest version of jquery i.e.: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

it will solved that error for sure.

1

you need to set compilation debug="false" in your web.config to use Jquery & css bundling regardless if .NET is running 4.0 or 4.5.

compilation debug="false" targetFramework="4.0"

0

check this link

var matched, browser;

jQuery.uaMatch = function( ua ) {
    ua = ua.toLowerCase();

    var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
        /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
        /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
        /(msie) ([\w.]+)/.exec( ua ) ||
        ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
        [];

    return {
        browser: match[ 1 ] || "",
        version: match[ 2 ] || "0"
    };
};

matched = jQuery.uaMatch( navigator.userAgent );
browser = {};

if ( matched.browser ) {
    browser[ matched.browser ] = true;
    browser.version = matched.version;
}

// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
    browser.webkit = true;
} else if ( browser.webkit ) {
    browser.safari = true;
}
Community
  • 1
  • 1
Amit Soni
  • 3,216
  • 6
  • 31
  • 50
0

can you please update your post with the two bundles you use for jQuery and jQueryUI.

you must be using two different versions of jQuery in your debug mode and release mode. Please take a look at http://api.jquery.com/jquery.browser/

you get n.browser because your script is minified, otherwise its $.browser

Amila
  • 3,711
  • 3
  • 26
  • 42
0

Reference your jquery files directly on the top of the view. Bundles don't work as they should sometimes:

 @section Scripts
{
<script src="../Scripts/jquery-1.10.1.js"></script>
<script src="../Scripts/jquery-1.10.1.min.js"></script>
<script src="../Scripts/jquery.validate.js"></script>
 .
 .
 .
etc.....

}

Fadeel
  • 231
  • 1
  • 6