2010-10-23 39 views
0

我正在運行原型腳本(lightbox),並且我想在每張圖片下方添加一個帶有url的額外鏈接,並將其添加到隨每張圖片一起更改的頁面中。更新原型中的鏈接href

我到目前爲止設法將a元素添加到正確的位置,但稍後在腳本中,我需要根據加載的圖像更新鏈接的href

有一個在腳本中的點,其中所述圖像被插入到收藏夾負荷後/導航燈箱:

showImage: function(){ 
    this.loading.hide(); 
    new Effect.Appear(this.lightboxImage, { 
     duration: this.resizeDuration, 
     queue: 'end', 
     afterFinish: (function(){ this.updateDetails(); }).bind(this) 
    }); 
    this.preloadNeighborImages(); 
}, 

它的完成後它運行updateDetails,它包括圖像標題。這似乎給我的完美的地方,也更新鏈接:

updateDetails: function() { 
    // if caption is not null 
    if (this.imageArray[this.activeImage][1] != ""){ 
     this.caption.update(this.imageArray[this.activeImage][1]).show(); 
    } 

    // if image is part of set display 'Image x of x' 
    if (this.imageArray.length > 1){ 
     this.numberDisplay.update(LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); 
    } 

/** slider effect cut from example code for the sake of brevity **/ 
} 

我試過基於這些功能使用的代碼許多變化,但似乎沒有任何工作。如何更新hrefid=toFilePage的鏈接?

我想它會是這樣的

this.toFilePage.href.update('http://example.com'); 

但這似乎沒有工作..

回答

0

我相信問題可能在於這部分內(在lightbox.js行175起)

(function() { 
var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; 
$w(ids).each(function(id) { 
    th[id] = $(id); 
}); 

})。defer();

這會創建對在其上方的Builder部分中創建的對象的引用。只需將您的ID添加到該列表中就可以了。

否則,您也可以通過$("myIdHere")訪問它。

+0

啊,謝謝!我目前被我的主機阻止了太多的http連接:/但我會盡快嘗試。將接受時固定:) – 2010-10-23 14:32:25