Unobtrusive Ajax stopped working after update jQuery to 1.9.0

后端 未结 8 1613
灰色年华
灰色年华 2020-11-28 09:42

I have just updated jQuery & jQuery UI to: jquery-1.9.0.min.js and jquery-ui-1.9.2.min.js

And... all my unobtrusive Ajax calls (Ajax.ActionLink, Ajax.BeginForm)

8条回答
  •  無奈伤痛
    2020-11-28 10:12

    Update: This issue has been fixed in the latest NuGet package. I've posted another answer to reflect this. https://stackoverflow.com/a/15539422/714309


    In jquery.unobtrusive-ajax.js, find and replace these four lines:

    1. $("a[data-ajax=true]").live("click", function (evt) {

      $(document).on("click", "a[data-ajax=true]", function (evt) {

    2. $("form[data-ajax=true] input[type=image]").live("click", function (evt) {

      $(document).on("click", "form[data-ajax=true] input[type=image]", function (evt) {

    3. $("form[data-ajax=true] :submit").live("click", function (evt) {

      $(document).on("click", "form[data-ajax=true] :submit", function (evt) {

    4. $("form[data-ajax=true]").live("submit", function (evt) {

      $(document).on("submit", "form[data-ajax=true]", function (evt) {

    You can also generate a new jquery.unobtrusive-ajax.min.js using WebGrease. From the Command Prompt, change to your solution folder and enter this command (assuming your project folder is called Web):

    packages\WebGrease.1.3.0\tools\WG.exe -m -in:Web\Scripts\jquery.unobtrusive-ajax.js -out:Web\Scripts\jquery.unobtrusive-ajax.min.js
    

提交回复
热议问题