summaryrefslogtreecommitdiff
path: root/includes/ajax.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-29 03:00:50 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-29 03:00:50 +0000
commit4e90d24dd9ff1474bf679f70a351dee371e87b51 (patch)
tree29a273840a1c145fcd5e43ca39a7c04504842a7e /includes/ajax.inc
parentff119bc0ccfa224279456c901904955a6b1f4d05 (diff)
downloadbrdo-4e90d24dd9ff1474bf679f70a351dee371e87b51.tar.gz
brdo-4e90d24dd9ff1474bf679f70a351dee371e87b51.tar.bz2
#818660 by yched, sun: Provide an AJAX command to invoke simple jQuery methods.
Diffstat (limited to 'includes/ajax.inc')
-rw-r--r--includes/ajax.inc33
1 files changed, 32 insertions, 1 deletions
diff --git a/includes/ajax.inc b/includes/ajax.inc
index 2fd7f6941..24824a63f 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -1002,7 +1002,7 @@ function ajax_command_changed($selector, $asterisk = '') {
* The 'css' command will instruct the client to use the jQuery css() method
* to apply the CSS arguments to elements matched by the given selector.
*
- * This command is implemented by Drupal.ajax.prototype.commands.insert()
+ * This command is implemented by Drupal.ajax.prototype.commands.css()
* defined in misc/ajax.js.
*
* @param $selector
@@ -1088,6 +1088,37 @@ function ajax_command_data($selector, $name, $value) {
}
/**
+ * Creates a Drupal AJAX 'invoke' command.
+ *
+ * The 'invoke' command will instruct the client to invoke the given jQuery
+ * method with the supplied arguments on the elements matched by the given
+ * selector. Intended for simple jQuery commands, such as attr(), addClass(),
+ * removeClass(), toggleClass(), etc.
+ *
+ * This command is implemented by Drupal.ajax.prototype.commands.invoke()
+ * defined in misc/ajax.js.
+ *
+ * @param $selector
+ * A jQuery selector string. If the command is a response to a request from
+ * an #ajax form element then this value can be NULL.
+ * @param $method
+ * The jQuery method to invoke.
+ * @param $arguments
+ * (optional) A list of arguments to the jQuery $method, if any.
+ *
+ * @return
+ * An array suitable for use with the ajax_render() function.
+ */
+function ajax_command_invoke($selector, $method, array $arguments = array()) {
+ return array(
+ 'command' => 'invoke',
+ 'selector' => $selector,
+ 'method' => $method,
+ 'arguments' => $arguments,
+ );
+}
+
+/**
* Creates a Drupal AJAX 'restripe' command.
*
* The 'restripe' command instructs the client to restripe a table. This is