提交后 Ajax.BeginForm OnSuccess 未执行

发布于 2024-11-04 09:58:19 字数 365 浏览 0 评论 0原文

我正在尝试使用 jquery 对话框来编辑 WebGrid 中的数据。在提交表单之前,一切都工作正常,浏览器不会返回到打开的当前页面,而是会转到控制器操作的 url。我在 WebGrid 中使用 HTML.ActionLink 将 jquery 行为添加到 WebGrid 的按钮,并且效果很好。它在 jquery 对话框中打开视图。该对话框定义了两个按钮:更新按钮和取消按钮。单击取消按钮不会执行任何操作。单击更新按钮会将浏览器带到控制器 URL,以使用项目 ID 进行编辑操作。我定义了 jquery.unobtrusive-ajax.js 库,并在 Web.config 文件中添加了 UnobtrusiveJavaScriptEnabled 键,尽管我不确定是否需要它。有谁经历过这种行为,非常感谢任何帮助!

I am trying to use a jquery dialog to edit data in an WebGrid. Everythings works fine until the Form is submitted, instead of return to the current page that is open the browser goes to the url of the controller action. I am using an HTML.ActionLink in the WebGrid that adds jquery behavior to a button the WebGrid, and that works fine. It opens the View in a jquery dialog. The dialog defines two buttons: an update button and a cancel button. Clicking the cancel button does nothing. Clicking the update button takes the browser to the controller url for the edit action with the item id. I have the jquery.unobtrusive-ajax.js library defined and I added the UnobtrusiveJavaScriptEnabled key in the Web.config file, although I am not sure it's needed. Has anyone experienced this behavior, any help is appreicated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

も让我眼熟你 2024-11-11 09:58:19

我在两种情况下遇到过这个问题:

  1. 事件处理程序没有被处理
    绑定到表单的提交事件,或者它没有抑制默认行为(通过 event.preventDefault();return false;)。
  2. 事件发生错误
    处理程序,导致它回落到
    默认行为。

好吧,这就是我在没有任何来源的情况下可以尽力提供的帮助。

I've experienced this problem in two situations:

  1. The event handler was not being
    binded to the form's submit event, or it was not suppressing the default behavior (through event.preventDefault(); or return false;).
  2. There was an error in the event
    handler, causing it to fall back to the
    default behavior.

Well this is how much I can try to help without any source.

红焚 2024-11-11 09:58:19

当我遇到这个问题时,我没有引用 jquery-Ajax.unobtrusive 库,因此请确保它也在那里

从我的条目 http://completedevelopment.blogspot.com/2011/02/unobstrusive-javascript-in-mvc-3-helps.html

1. Set the mentioned flag in the web.config: <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
2. Include a reference to the jQuery library ~/Scripts/jquery-1.4.4.js
3. Include a reference to the library that hooks this magic at ~/Scripts/jquery.unobtrusive-ajax.js

When I had this issue I wasnt referencing the jquery-Ajax.unobtrusive library so ensure that's there too

From my entry at http://completedevelopment.blogspot.com/2011/02/unobstrusive-javascript-in-mvc-3-helps.html

1. Set the mentioned flag in the web.config: <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
2. Include a reference to the jQuery library ~/Scripts/jquery-1.4.4.js
3. Include a reference to the library that hooks this magic at ~/Scripts/jquery.unobtrusive-ajax.js
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文