public/javascripts/yui/carousel/carousel-debug.js
function (item, index) {
            var carousel = this,
                className,
                content,
                elId,
                numItems = carousel.get("numItems"),
                oel,
                el = item;

            if (!item) {
                return false;
            }

            if (JS.isString(item) || item.nodeName) {
                content = item.nodeName ? item.innerHTML : item;
            } else if (JS.isObject(item)) {
                content = item.content;
            } else {
                YAHOO.log("Invalid argument to replaceItem", "error", WidgetName);
                return false;
            }

            if (JS.isUndefined(index)) {
                YAHOO.log("Index must be defined for replaceItem", "error", WidgetName);
                return false;
            } else {
                if (index < 0 || index >= numItems) {
                    YAHOO.log("Index out of bounds in replaceItem", "error", WidgetName);
                    return false;
                }

                oel = carousel._itemsTable.items[index];
                if(!oel){
                    oel = carousel._itemsTable.loading[index];
                    carousel._itemsTable.items[index] = undefined;
                }

                carousel._itemsTable.items.splice(index, 1, {
                    item      : content,
                    className : item.className || "",
                    id        : Dom.generateId()
                });

                el = carousel._itemsTable.items[index];
            }
            carousel.fireEvent(itemReplacedEvent,
                    { newItem: el, oldItem: oel, pos: index, ev: itemReplacedEvent });

            return true;
        }
function (item, index) {
            var carousel = this,
                className,
                content,
                elId,
                numItems = carousel.get("numItems"),
                oel,
                el = item;

            if (!item) {
                return false;
            }

            if (JS.isString(item) || item.nodeName) {
                content = item.nodeName ? item.innerHTML : item;
            } else if (JS.isObject(item)) {
                content = item.content;
            } else {
                YAHOO.log("Invalid argument to replaceItem", "error", WidgetName);
                return false;
            }

            if (JS.isUndefined(index)) {
                YAHOO.log("Index must be defined for replaceItem", "error", WidgetName);
                return false;
            } else {
                if (index < 0 || index >= numItems) {
                    YAHOO.log("Index out of bounds in replaceItem", "error", WidgetName);
                    return false;
                }

                oel = carousel._itemsTable.items[index];
                if(!oel){
                    oel = carousel._itemsTable.loading[index];
                    carousel._itemsTable.items[index] = undefined;
                }

                carousel._itemsTable.items.splice(index, 1, {
                    item      : content,
                    className : item.className || "",
                    id        : Dom.generateId()
                });

                el = carousel._itemsTable.items[index];
            }
            carousel.fireEvent(itemReplacedEvent,
                    { newItem: el, oldItem: oel, pos: index, ev: itemReplacedEvent });

            return true;
        }
function ( item , index ) { var carousel = this , className , content , elId , numItems = carousel . get ( "numItems" ) , oel , el = item ; if ( ! item ) { return false ; } if ( JS . isString ( item ) || item . nodeName ) { content = item . nodeName ? item . innerHTML : item ; } else if ( JS . isObject ( item ) ) { content = item . content ; } else { YAHOO . log ( "Invalid argument to replaceItem" , "error" , WidgetName ) ; return false ; } if ( JS . isUndefined ( index ) ) { YAHOO . log ( "Index must be defined for replaceItem" , "error" , WidgetName ) ; return false ; } else { if ( index < 0 || index >= numItems ) { YAHOO . log ( "Index out of bounds in replaceItem" , "error" , WidgetName ) ; return false ; } oel = carousel . _itemsTable . items [ index ] ; if ( ! oel ) { oel = carousel . _itemsTable . loading [ index ] ; carousel . _itemsTable . items [ index ] = undefined ; } carousel . _itemsTable . items . splice ( index , 1 , { item : content , className : item . className || "" , id : Dom . generateId ( ) } ) ; el = carousel . _itemsTable . items [ index ] ; } carousel . fireEvent ( itemReplacedEvent , { newItem : el , oldItem : oel , pos : index , ev : itemReplacedEvent } ) ; return true ; }
Replace an item at index witin Carousel.

@method replaceItem
@public
@param item {String | Object | HTMLElement} The item to be appended
to the Carousel. If the parameter is a string, it is assumed to be
the content of the newly created item. If the parameter is an
object, it is assumed to supply the content and an optional class
and an optional id of the newly created item.
@param index {Number} The position to where in the list (starts from
zero).
@return {Boolean} Return true on success, false otherwise
Replace an item at index witin Carousel .