2011-08-23 5 views
0

나는 그러나 나는이 작업을 수행하는 방법, 나 또한 것 아무 생각이 없다, 일부 다음과 같습니다 HTML,하기 ShareThis 및 JQuery와 도움

<div class="suit-gallery"> 
    <img src="../images/galleries/business/DSC_0035_sm.jpg" alt="Stylish button 2 business suit with contrast buttonholes light weight high twist cool wool" width="164" height="247" /> 
    <div class="suit-gallery-btn"> 
    <a href="../images/galleries/business/DSC_0035.jpg" rel="lightbox[business]" title="Stylish button 2 suit with contrast buttonholes light weight high twist cool wool Holland &amp; Sherry from £695, choice of 90 designs/colours">Click for more information</a> 
</div> 
</div> 

<div class="suit-gallery"> 
    <img src="../images/galleries/business/DSC_0010_sm.jpg" alt="Classic button 2 business suit with an out ticket pocket. Grey wool Holland &amp; Sherry Perennial" width="164" height="247" /> 
    <div class="suit-gallery-btn"> 
    <a href="../images/galleries/business/DSC_0010.jpg" rel="lightbox[business]" title="Classic button 2 suit with an out ticket pocket. Grey wool Holland &amp; Sherry Perennial from £895, choice of 120 designs/colours" >Click for more information</a> 
</div> 
</div> 

<div class="clear">&nbsp;</div> 

<div class="suit-gallery"> 
    <img src="../images/galleries/business/DSC_0024_sm.jpg" alt="Modern 2 button business suit grey 100% Yorkshire worsted" width="164" height="247" /> 
    <div class="suit-gallery-btn"> 
    <a href="../images/galleries/business/DSC_0024.jpg" rel="lightbox[business]" title="Modern 2 button suit 100% Yorkshire worsted from £795 choice of 85 designs/colours" >Click for more information</a> 
</div> 

내가 .suit-gallery-btn의 각 인스턴스에하기 ShareThis 메일 링크를 추가하고자하고 있습니다 이미지 옵션으로 자막 옵션에 링크의 링크의 제목, 또한 이미지의 URL을 같은, 아래, 내가 현재 가지고있는 것입니다

jQuery(document).ready(function(){ 
    stWidget.addEntry({ 
    "service":"email", 
    "element": document.getElementById('button_1'), 
    "url":"http://sharethis.com", 
    "title":"What do you think to this suit?", 
    "type":"large", 
    "text":"What do you think to this suit?" , 
    "image": "", 
    "summary":"" 
    }); 
}); 

나는 또한 내가에 따라 요소를 선택해야 할 것이라는 점을 알고있다 이드가 아닌 클래스와 나는 많은 것을 위해서 이것을해야한다 .suit-gallery-btn 거기있다.

나는 혀를 잃었습니다. 이 같은

답변

1

시도 뭔가 : http://jsfiddle.net/RR26b/

(가 유효하지 않은 이미지 참조에서 오류가 있습니다, 그리고하기 ShareThis 발행인 키의 부족,하지만 개념은 다음과 같습니다

$(".suit-gallery-btn").each(function(){ 

    $(this).append("<span class='share-span'></span>"); // ShareThis button will be inserted in this span, which we are appending to each <div class="suit-gallery-btn"> 

    var suitLink = $(this).find('a'); // the "click more information" link. you will need the href and title from this element. 

    stWidget.addEntry({ 
     "service":"email", 
     "element": $(this).find('.share-span')[0], 
     "url":suitLink.attr('href'), 
     "title":suitLink.attr('title'), 
     "type":"large", 
     "text":suitLink.attr('title'), 
     "image": suitLink.attr('href'), 
     "summary":suitLink.attr('title') 
    }); 


}); 

을 보여주기 위해 JS 바이올린입니다 작동해야 함)

+0

많은 분들께 고마워. 각 버튼에 대해 동일한 정보를 보여주는 sharethis 위젯을 어떻게 중지시킬 수 있습니까? 내 링크 중 하나에서 위젯을 실행하면 모든 공유 버튼에 데이터가 사용됩니다 – Udders