Asp.net Core中的Ajax帮助器标签文档 [英] Ajax helper tags documentation in Asp.net Core

查看:83
本文介绍了Asp.net Core中的Ajax帮助器标签文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Asp.net Core中是否有Ajax帮助器标签文档的链接.我正在尝试使用asp.net核心学习ajax,但是我没有找到有关它的文档. 在asp.net mvc中,我们使用@ Ajax.Form,然后使用AjaxOptions方法来处理ajax.经过数小时的搜索,我找到了此链接. https://dotnetthoughts.net/jquery-unobtrusive-ajax-helpers- in-aspnet-core/ 在此链接中,有一种在asp.net核心中使用ajax的方法. 我在我的项目中实现了它并取得了成功. 然后我搜索了它的文档,但是什么也没找到. 我想要它的文档链接.请任何人帮助它的文档

Is there is any link for Ajax helper tags documentation in Asp.net Core. I am trying to learn ajax with asp.net core but i found no documentation for it. In asp.net mvc we use @Ajax.Form and then uses AjaxOptions method for work on ajax. After many hours search i found this link. https://dotnetthoughts.net/jquery-unobtrusive-ajax-helpers-in-aspnet-core/ In this link there is a way work with ajax in asp.net core. I implement it in my project and successful. Then i search for its documentation but i found nothing. I want its documentation link.Please anybody help for its documentation

推荐答案

ASP.NET Core中没有服务器端帮助程序,例如@Ajax.Form.您可能会为类似的功能编写自己的标签帮助程序,但我还没有看到有人这样做.一般的想法是,当您要具有客户端行为时,编写实际的JavaScript.将这些东西隐藏在服务器端魔术背后通常不是最好的主意.

There are no server-side helpers, like @Ajax.Form, in ASP.NET Core. You could probably write your own tag helpers for similar features but I haven’t seen anyone do this. The general idea is to write actual JavaScript when you want to have client-side behavior. Hiding these things behind server-side magic is usually not the best idea.

jquery-ajax-unobtrusive 是一个JavaScript软件包,可将客户端行为添加到在最终呈现的页面中查找各种属性,以在标准表单的顶部添加功能.因此,这将是一个完全基于JavaScript的解决方案.

jquery-ajax-unobtrusive is a JavaScript package that adds client-side behavior to look for various attributes in the final rendered page to add functionality on top of your standard forms. So this would be a fully JavaScript-based solution.

不幸的是,似乎没有关于它的文档.您可以查看其源代码,以了解可能或不可能的情况

Unfortunately, there does not seem to be documentation about it. You can take a look at its source code to figure out what may or may not be possible.

通过快速查看源代码(免责声明:无需亲自测试功能),这似乎是软件包支持的数据属性和可用功能:

From taking a quick look at the source (disclaimer: without testing the functionality myself), this seems to be the supported data attributes and available functionality of the package:

  • data-ajax="true" –启用表单功能.
  • data-ajax-update –使用模式,用AJAX结果更新的元素的选择器.
  • data-ajax-mode
    • data-ajax="true" – To enable the functionality for a form.
    • data-ajax-update – Selector for the elements that are updated with the AJAX result, using the mode.
    • data-ajax-mode
      • data-ajax-mode="before" – Prepends the data to the element.
      • data-ajax-mode="after" – Appends the data to the element.
      • data-ajax-mode="replace-with" – Replaces the element with the data.
      • Otherwise sets the HTML content of the element to the data.

      回调函数等效于jQuery的beforeSendcompletesuccessfailure.从外观上,您可以使用函数的JavaScript对象路径指定回调.

      The callback functions are the equivalent of jQuery’s beforeSend, complete, success, and failure. From how it looks, you can specify the callbacks using a JavaScript object path to the function.

      例如,data-ajax-success="foo.bar.onSuccess"将调用函数foo.bar.onSuccess(),即它将在window中查找对象foo,获取其bar成员,然后在其上调用onSuccess.

      For example data-ajax-success="foo.bar.onSuccess" will call the function foo.bar.onSuccess(), i.e. it will look for an object foo in the window, get its bar member, and call onSuccess on that.

      这篇关于Asp.net Core中的Ajax帮助器标签文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆