2013-04-09 64 views
0

環境中的目標元素我想操縱一個特定的元素,其中包含一段文字,我想包裹它在一個href,雖然我使用css背景紅色來證明元素的目標。在ajaxComplete

我使用的是Galleria 1.2.8,我目前有一個函數,它會在ajaxComplete上運行並且工作。

這是當前工作的功能:

// dynamically create data-links for all gallery items 
$(document).ajaxComplete(function() { 
    $('#galleria a').each(function() { 
     var $href = $(this).attr('href'); 
     $(this).children().attr('data-link',$href); 
    }); 
    $('.galleria-info-description:contains("NN")').css('background', 'red'); 
}); 

最後一行是功能不能正常工作的一部分。

這是HTML的簡化基本塊,是動態創建:

<div class="galleria-container"> 
    <div class="galleria-stage"> 
    </div> 
    <div class="galleria-thumbnails-container"> 
    </div> 
    <div class="galleria-info"> 
     <div class="galleria-info-text"> 
      <div class="galleria-info-description"> 
       NN Contemporary Art 
      </div> 
     </div> 
     <div class="galleria-info-link"> 
     </div> 
     <div class="galleria-info-close"> 
     </div> 
    </div> 
</div> 

我已經嘗試了不少的變化,創建一個變量來保存的內容和操作這些。通過對其父母進行深入探討,似乎什麼都不起作用。我可以在ajaxComplete中完全從頁面中刪除#galleria id,但似乎無法獲取對象中返回的特定元素。

TIA。

+0

確實廣場已經建成時最後一個選擇器被使用?你能指出何時何地初始化環球免稅店? – David 2013-04-09 13:08:44

+0

它位於此代碼塊的下方,朝向頁腳。你可以在這裏看到代碼:http://dev.jessicaharby.com – lharby 2013-04-09 13:11:28

回答

0

所以這是一個有點笨重,但是我查了廣場文檔瀏覽: http://galleria.io/docs/api/methods/#retrieval

現在我剛纔的Galleria初始化之前添加以下代碼:

Galleria.ready(function(options) { 
$targetElem = (this.getData([10])); 
$targetElem.description = '<a href="http://www.nncontemporaryart.org/exhibitions/guests- hosts" target="_blank">NN Contemporary Art Northampton</a>'; 
});