summaryrefslogtreecommitdiff
path: root/misc/drupal.js
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-08-31 05:51:08 +0000
committerDries Buytaert <dries@buytaert.net>2009-08-31 05:51:08 +0000
commite6e29ac1b0d6780241ced3d5ebcb0558e219e468 (patch)
treea6bdbf6b69ab26e54295d8063e7d1c839cd42f3a /misc/drupal.js
parent41dca3c4e0ec3d355977735f74af2e49ea0eedd7 (diff)
downloadbrdo-e6e29ac1b0d6780241ced3d5ebcb0558e219e468.tar.gz
brdo-e6e29ac1b0d6780241ced3d5ebcb0558e219e468.tar.bz2
- Patch #444344 by kkaefer, sun, Rob Loach: this change introduces a jQuery .once() method which streamlines the way behavior functions work. Previously, we had to manually ensure that an element is only initialized once. Usually, this happens by adding classes and selecting only those elements which do not have that class. However, this process can be separated out into a jQuery ‘filtering’ function which does all the grunt work.
Diffstat (limited to 'misc/drupal.js')
-rw-r--r--misc/drupal.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/misc/drupal.js b/misc/drupal.js
index dbd057bb9..ea688a499 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -12,7 +12,6 @@ if ($ === undefined) {
};
}
-
(function ($) {
/**
@@ -38,10 +37,15 @@ if ($ === undefined) {
* loaded, feeding in an element to be processed, in order to attach all
* behaviors to the new content.
*
- * Behaviors should use a class in the form behaviorName-processed to ensure
- * the behavior is attached only once to a given element. (Doing so enables
- * the reprocessing of given elements, which may be needed on occasion despite
- * the ability to limit behavior attachment to a particular element.)
+ * Behaviors should use
+ * @code
+ * $(selector).once('behavior-name', function () {
+ * ...
+ * });
+ * @endcode
+ * to ensure the behavior is attached only once to a given element. (Doing so
+ * enables the reprocessing of given elements, which may be needed on occasion
+ * despite the ability to limit behavior attachment to a particular element.)
*
* @param context
* An element to attach behaviors to. If none is given, the document element