How to resolve the “Exception: Object does not support property or method on incorrect reference of jQuery”?
Problem:
When the necessary scripts’ reference order is changed or when the jQuery is referred more than once, the exception, “object does not support property or method” occurs. This is because the scripts’ reference is dependent on some other scripts, and when the order is changed, the dependant function or methods may not work properly, throwing the exception.
For example, when you refer to the jsrender.min.js before the jQuery.1.10.2.min.js, this throws the exception, “Object does not support property or method ‘template’” because the jsrender requires the jQuery reference.
Solution:
You can overcome this issue by adding the necessary script reference in the proper order. Use the following order to refer to the necessary scripts.
<link href="@Url.Content("~/Content/ej/web/Default-theme/ej.widgets.all.min.css")" rel="stylesheet" /> <script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script> <script src="@Url.Content("~/Scripts/jsrender.min.js")"></script> <script src="@Url.Content("~/Scripts/jquery.easing-1.3.min.js")"></script> <script src="@Url.Content("~/Scripts/jquery.globalize.min.js")"></script> <script src="@Url.Content("~/Scripts/ej/ej.web.all.min.js")"></script> <script src="@Url.Content("~/Scripts/ej/ej.unobtrusive.min.js")"></script> |
Make sure that the jQuery script is not referred once again after the ej.web.all.min.js reference. Refer to the following code example.
<link href="@Url.Content("~/Content/ej/web/Default-theme/ej.widgets.all.min.css")" rel="stylesheet" /> <script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script> <script src="@Url.Content("~/Scripts/jsrender.min.js")"></script> <script src="@Url.Content("~/Scripts/jquery.easing-1.3.min.js")"></script> <script src="@Url.Content("~/Scripts/jquery.globalize.min.js")"></script> <script src="@Url.Content("~/Scripts/ej/ej.web.all.min.js")