2013-05-29 34 views
1

我有一個ASP.NET MVC3應用程序,我已經升級到JQuery 2.0.1,不幸的是這有一些令人不快的副作用。 (More info hereAjax.ActionLink生成的ASP.NET代碼在升級到JQuery 2.0.1後停止工作

目前我只有一個未解決的問題:由@ Ajax.ActionLink生成的HTML鏈接不再調用適當的js代碼,而是被瀏覽器視爲常規鏈接。

有問題的頁面包含以下js文件:

<script src="/Scripts/jquery-2.0.1.min.js" type="text/javascript"></script> 
<script src="/Scripts/modernizr-2.6.2.js" type="text/javascript"></script> 
<script src="/Scripts/jquery-ui-1.10.3.min.js" type="text/javascript"></script> 

<script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script> 
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript">script> 
<script src="~/Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script> 
<script src="/Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script> 
<script src="/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"> </script> 

我不得不手動更新jquery.unobtrusive-ajax.min.js文件來解決另一個問題(由on更換live)。

Ajax.ActionLink如下所示:

@Ajax.ActionLink("Delete", "Delete", "InputResources", 
       new { id = Model[i].ID }, 
       new AjaxOptions 
       { 
        HttpMethod = "DELETE", 
        Confirm = "Are you sure you want to delete?", 
        OnComplete = "window.location.href='/Projects/InputResources/" + ViewBag.ProjectID + "'" 
       }) 

的HTML生成,似乎聲音看:

<a href="/InputResources/Delete/5" data-ajax-method="DELETE" data-ajax-confirm="Are you sure you want to delete?" data-ajax-complete="window.location.href='/Projects/InputResources/2'" data-ajax="true">Delete</a> 

任何人都可以提出什麼js文件,我需要怎樣才能得到這個鏈接修改再次正確工作?

+0

我和你有同樣的問題,並希望看到這個解決方案.. – formatc

回答

1

這裏是解決了這個問題對我來說:

這將更新您的jQuery驗證腳本到最新版本:

PM> Install-Package jQuery.Validation 

這將更新你的jQuery不顯眼的驗證腳本到最新版本:

PM> Install-Package jQuery.Ajax.Unobtrusive 

確保這兩個都包含在您的頁面後jQuery庫, 如果你不這樣做,它將不起作用。

相關問題