Permalink
Browse files

added more methods to HTMLElement

  • Loading branch information...
1 parent aaceaba commit 6b1a32c6aad894920ca2d3853a9ae075f923db1c @juzna committed Jan 13, 2011
Showing with 35 additions and 0 deletions.
  1. +35 −0 src/prototype/dom/dom.js
@@ -3638,5 +3638,40 @@ Element.addMethods({
while (i--) purgeElement(descendants[i]);
return null;
+ },
+
+ /**
+ * Element.load(@element, url, [options]) -> Ajax.Request
+ *
+ * More convenient way to call Ajax.Updater
+ *
+ * Example:
+ * $('news').load('news.html');
+ */
+ load: function(element, url, options) {
+ return new Ajax.Updater(element, url, options);
+ },
+
+ /**
+ * Append more children at once
+ * See appendChild
+ *
+ * Example:
+ * $('news').appendChildren(div1, div2, div3)
+ */
+ appendChildren: function(element) {
+ var args = $A(arguments);
+ args.shift(); // Skip first argument
+
+ for(var i = 0; i < args.length; i++) element.appendChild(args[i]);
+ return element;
+ },
+
+ /**
+ * Checks if element is in document's body (otherwise it could be already removed from DOM but we have reference to it)
+ **/
+ inBody: function(el) {
+ while(el && el.parentElement) el = el.parentElement;
+ return (el && el.tagName == 'HTML');
}
});

0 comments on commit 6b1a32c

Please sign in to comment.