Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get value of the property 'unobtrusive': object is null or undefined

When I run my code I get that error:

Unable to get value of the property 'unobtrusive': object is null or undefined

It would be normal but I'm adding all the jquery stuff I need:

jquery.validate-vsdoc.js
jquery.validate.js
jquery.validate.min.js
jquery.validate.unobtrusive.js
jquery.validate.unobtrusive.min.js
jquery.unobtrusive-ajax.js
jquery.unobtrusive-ajax.min.js

I load this on my Main form:

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

And my bundle config has:

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

I have in my Script folder all the files related.

Why am I getting this error? Comment if you need to see any file and I will gladly post it

EDIT:

The scripts are loaded (I checked) This line gives the error:

jQuery.validator.unobtrusive.prototype.parse.call(this, selector);

ERROR:

SCRIPT5007: Unable to get value of the property 'unobtrusive': object is null or undefined 
like image 767
AAlferez Avatar asked Jun 06 '13 16:06

AAlferez


1 Answers

Found the problem.

I had another partial view which was adding a script "~/Scripts/jquery..."

So I had the bundle in the main view and this one in a partial of a menu that was always rendering. Seems like just the last one was being considered and the Unobtrusive wasn't added there. Removing it from the partial view and leaving just the one in the main view resolved it.

Thanks for the guesses.

like image 164
AAlferez Avatar answered Oct 03 '22 11:10

AAlferez