• <i id='QBzpg'><tr id='QBzpg'><dt id='QBzpg'><q id='QBzpg'><span id='QBzpg'><b id='QBzpg'><form id='QBzpg'><ins id='QBzpg'></ins><ul id='QBzpg'></ul><sub id='QBzpg'></sub></form><legend id='QBzpg'></legend><bdo id='QBzpg'><pre id='QBzpg'><center id='QBzpg'></center></pre></bdo></b><th id='QBzpg'></th></span></q></dt></tr></i><div id='QBzpg'><tfoot id='QBzpg'></tfoot><dl id='QBzpg'><fieldset id='QBzpg'></fieldset></dl></div>

      • <bdo id='QBzpg'></bdo><ul id='QBzpg'></ul>

    1. <small id='QBzpg'></small><noframes id='QBzpg'>

      1. <tfoot id='QBzpg'></tfoot><legend id='QBzpg'><style id='QBzpg'><dir id='QBzpg'><q id='QBzpg'></q></dir></style></legend>

      2. Drupal 7 Field API:如何以编程方式发送表单元素的#ajax属性中指定的AJAX请求?

        时间:2024-04-19

              • <tfoot id='3AnB0'></tfoot>

                  <bdo id='3AnB0'></bdo><ul id='3AnB0'></ul>
                • <i id='3AnB0'><tr id='3AnB0'><dt id='3AnB0'><q id='3AnB0'><span id='3AnB0'><b id='3AnB0'><form id='3AnB0'><ins id='3AnB0'></ins><ul id='3AnB0'></ul><sub id='3AnB0'></sub></form><legend id='3AnB0'></legend><bdo id='3AnB0'><pre id='3AnB0'><center id='3AnB0'></center></pre></bdo></b><th id='3AnB0'></th></span></q></dt></tr></i><div id='3AnB0'><tfoot id='3AnB0'></tfoot><dl id='3AnB0'><fieldset id='3AnB0'></fieldset></dl></div>

                  <small id='3AnB0'></small><noframes id='3AnB0'>

                  <legend id='3AnB0'><style id='3AnB0'><dir id='3AnB0'><q id='3AnB0'></q></dir></style></legend>
                    <tbody id='3AnB0'></tbody>
                  本文介绍了Drupal 7 Field API:如何以编程方式发送表单元素的#ajax属性中指定的AJAX请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Drupal 7 字段 API 通过 AJAX 重新加载我的部分表单.我有一个可以拨打电话的按钮,但我想删除它并以编程方式拨打电话作为对特定事件的响应.这是我的 AJAX 按钮代码:

                  I'm using Drupal 7 field API to reload part of my form through AJAX. I have a button which makes the call but I would like to remove it and make the call programmatically as a response to a specific event. Here is my code for the AJAX button:

                  $form['documents']['reload_document_list_button'] = array(
                    '#type' => 'button',
                    '#value' => 'Обновить список документов',
                    '#ajax' => array(
                      'callback' => 'reload_document_list',
                      'wrapper' => 'document-list',
                      'method' => 'replace',
                    ),
                  );
                  

                  (参见 http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#ajax 了解详情.)有没有办法做到这一点?

                  (See http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#ajax for details.) Is there a way to do this?

                  附:我知道我可以设置按钮的样式以使其不可见并触发点击"事件,但我正在寻找一种更简洁的方法来做到这一点.

                  P.S. I know I can style the button to make it invisible and trigger 'click' event, but I am looking for a neater way to do this.

                  推荐答案

                  我认为有两种方法可以做到:

                  There are two ways you can do this, I think:

                  首先,您可能已经阅读过的 #ajax 属性接受 event 键.对于按钮元素,默认情况下,该事件为mousedown.(您可以检查它这里)您可以将其更改为自定义事件,例如 customEvent 并从您的 Javascript 代码中触发此自定义事件,如 jQuery('#button-id').trigger('customEvent');.

                  First, the #ajax property as you might have read accepts an event key. For the button element by default, this event is mousedown. (You can check it here) You can change it to a custom event, say customEvent and trigger this custom event from your Javascript code as jQuery('#button-id').trigger('customEvent');.

                  或者,您可以使用 #ajax 属性本身.设置 AJAX 端点(使用 hook_menu)并将 reload_document_list 设置为其回调.添加自定义 Javascript 以发出请求并处理响应.您可以查看使用 misc/ajax.js 中的 #ajax 时 Drupal 发送 AJAX 请求的方式,并在需要时将其用作参考.

                  Alternatively, you can chuck the #ajax property itself. Set up an AJAX endpoint (using hook_menu) and set reload_document_list as its callback. Add custom Javascript to make the request and handle the response. You can take a look at the way Drupal sends the AJAX request when you use #ajax from misc/ajax.js and use that as a reference if you want.

                  这篇关于Drupal 7 Field API:如何以编程方式发送表单元素的#ajax属性中指定的AJAX请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:IE7 (IETEster) 中的@fontface 无法正常工作 下一篇:jQuery 无法正确渲染

                  相关文章

                  1. <i id='0ron1'><tr id='0ron1'><dt id='0ron1'><q id='0ron1'><span id='0ron1'><b id='0ron1'><form id='0ron1'><ins id='0ron1'></ins><ul id='0ron1'></ul><sub id='0ron1'></sub></form><legend id='0ron1'></legend><bdo id='0ron1'><pre id='0ron1'><center id='0ron1'></center></pre></bdo></b><th id='0ron1'></th></span></q></dt></tr></i><div id='0ron1'><tfoot id='0ron1'></tfoot><dl id='0ron1'><fieldset id='0ron1'></fieldset></dl></div>
                    • <bdo id='0ron1'></bdo><ul id='0ron1'></ul>

                      <legend id='0ron1'><style id='0ron1'><dir id='0ron1'><q id='0ron1'></q></dir></style></legend>

                    1. <small id='0ron1'></small><noframes id='0ron1'>

                      <tfoot id='0ron1'></tfoot>