Uncaught TypeError: undefined is not a function on loading jquery-min.js

前端 未结 13 792
北荒
北荒 2020-11-28 22:55

I\'m building a normal webpage which requires me to load about five CSS files and ten Javascript files.

  • When loading them separately in the HTML page, my webpa
13条回答
  •  日久生厌
    2020-11-28 23:47

    I had this problem recently with the jQuery Validation plug-in, using Squishit, also getting the js error:

    "undefined is not a function"

    I fixed it by changing the reference to the unminified jquery.validate.js file, rather than jquery.validate.min.js.

    @MvcHtmlString.Create(
        @SquishIt.Framework.Bundle.JavaScript()
            .Add("~/Scripts/Libraries/jquery-1.8.2.min.js")
            .Add("~/Scripts/Libraries/jquery-ui-1.9.1.custom.min.js")
            .Add("~/Scripts/Libraries/jquery.unobtrusive-ajax.min.js")
            .Add("~/Scripts/Libraries/jquery.validate.js")
            .Add("~/Scripts/Libraries/jquery.validate.unobtrusive.js")
             ... more files
    

    I think that the minified version of certain files, when further compressed using Squishit, for example, might in some cases not deal with missing semi-colons and the like, as @Dustin suggests, so you might have to experiment with which files you can doubly compress, and which you just leave to Squishit or whatever you're bundling with.

提交回复
热议问题