Rob Kinyon - DOM.Insert-0.02

Documentation | Source

NAME

DOM.Insert.Top

DESCRIPTION

This provides an easy way to add arbitrary HTML as the first child of a given element in the DOM.

CLASSES

DOM.Insert.Top

This takes in its constructor an element and content to be inserted. It will insert the content as the first child of element.

  // Assume someElement is a <UL>
  new DOM.Insert.Top( someElement, '<li id=4>Value</li>' );

SUPPORT

Currently, there is no mailing list or IRC channel. Please send bug reports and patches to the author.

AUTHOR

Rob Kinyon (rob.kinyon@iinteractive.com)

Originally written by Sam Stephenson (sam@conio.net)

My time is generously donated by Infinity Interactive, Inc. http://www.iinteractive.com

/*

*/

try {
    JSAN.use( 'DOM.Insert' );
} catch (e) {
    throw "DOM.Insert.Top requires JSAN to be loaded";
}

/*

*/

DOM.Insert.Top = Class.subclass( 'DOM.Insert.Top', DOM.Insert, {
    adjacency: 'afterBegin'
   ,initializeRange: function() {
        this.range.selectNodeContents(this.element);
        this.range.collapse(true);
    }
   ,insertContent: function() {  
        this.element.insertBefore(this.fragment, this.element.firstChild);
    }
});

/*

*/