ASP.NET MVC 3 + jQuery is not working after MVC Tools Update?
I'm wondering what happen with jQuery using on ASP.NET MVC any jQuery code is not working specially in click methods
I'm using Razor view开发者_Go百科 engines.
Any notice about this issue?
$(document).ready(function () {
$('.simpledialog').simpleDialog();
});
$('#button').click(function(){
//ToDo
});
I've added the dialog script and css :
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
but it always breaks when button is clicked and I receive an error :
Microsoft JScript runtime error :
Object doesn't support property or method 'dialog'
If the solution above does not work and you're also using Telerik controls, you should add .jQuery(false) to the ScriptRegistrar tag at the bottom of your Views/Shared/_Layout.cshtml file. If you don't do this, the asset.axd call is also loading (blindly) jQuery.
Check what jQuery your Scripts folder contains and then check your Layout.cshtml, if it has reference to correct file. There might be differences in versions.
Edit: Also do check the packages.config
file in your MVC application root directory. There is a reference to jQuery package. So you might need to correct it to your actual version, or remove that jQuery package.
Dont know if it helps anyone, but i had this problem for ages - then realised one of my partial views for including a free calendar control was referencing an earlier version of jQuery and stopping the dialog from working!
精彩评论