JS 파일에서

// To SNS
 bd.find('.to_sns a').click(function(){
  var t = $(this);
  var type = t.data('type');
  var p = t.parent();
  var href = p.data('url');
  var permanentUrl = p.data('permanenturl');
  var title = p.data('title');
  var img = bd.find('div.xe_content img:first').attr('src');
  if(!type){
   return;
  } else if(type=="facebook"){
   var loc = '//www.facebook.com/sharer/sharer.php?u='+href+'&t='+title;
  } else if(type=="twitter"){
   loc = '//twitter.com/home?status='+encodeURIComponent(title)+' '+href;
  } else if(type=="google"){
   loc = '//plus.google.com/share?url='+href;
  } else if(type=="pinterest"){
   if(!img){
    alert('No Image!');
    return false;
   };
   loc = '//www.pinterest.com/pin/create/button/?url='+href+'&media='+img+'&description='+encodeURIComponent(title);
  } else if(type=="kakaostory"){
   loc = 'https://story.kakao.com/share?url='+encodeURIComponent(href);
  } else if(type=="band"){
   loc = 'http://www.band.us/plugin/share?body='+encodeURIComponent(title)+'%0A'+encodeURIComponent(href);
  } else if(type=="kakao"){
   if(img){
    Kakao.Link.sendTalkLink({
     label:title,
     image:{
      src:img,
      width: '300',
      height: '200'
     },
     webLink:{
      text:permanentUrl,
      url:href
     }
    });
   } else {
    Kakao.Link.sendTalkLink({
     label:title,
     webLink:{
      text:permanentUrl,
      url:href
     }
    });
   };
   return false;
  };
  window.open(loc);
  return false;
 });

 

이걸 복사해넣고

 

read.html 파일에

  <!--// SNS -->
  <div class="to_sns big" style="text-align:{$mi->to_sns_big}" data-url="{$sns_link}" data-permanenturl="{$oDocument->getPermanentUrl()}" data-title="{$sns_title}">
   <a class="facebook bubble" href="#" data-type="facebook" title="To Facebook"><b class="ico_sns facebook">Facebook</b></a>
   <a class="twitter bubble" href="#" data-type="twitter" title="To Twitter"><b class="ico_sns twitter">Twitter</b></a>
   <a class="google bubble" href="#" data-type="google" title="To Google"><b class="ico_sns google">Google</b></a>
   <!--@if(Mobile::isMobileCheckByAgent())-->
   <a class="kakaostory" href="storylink://posting?post={$oDocument->getPermanentUrl()}&appid=m.kakao.com&appver=1.0&apiver=1.0&appname={$mi->title}"><b class="ico_sns kakaostory">KakaoStory</b></a>
   <a class="band" href="bandapp://create/post?text={$sns_title}%0A{$sns_link}"><b class="ico_sns band">Band</b></a>
   <a class="kakao" href="#" data-type="kakao"><b class="ico_sns kakao">Kakao</b></a>
   <a class="line" href="line://msg/text/?{$sns_title}%0D%0A{$sns_link}"><b class="ico_sns line">Line</b></a>
   <!--@else-->
   <a class="kakaostory bubble" href="#" data-type="kakaostory" title="To KakaoStory"><b class="ico_sns kakaostory">KakaoStory</b></a>
   <a class="band bubble" href="#" data-type="band" title="To Band"><b class="ico_sns band">Band</b></a>
   <!--@end-->
  </div>

 

이걸 붙여넣었는데 제대로 작동되지 않는 이유가 뭔가요?

 

제 생각엔 이부분이 잘못되지 않았나 싶은데,

 

자바스크립트  bd.find('.to_sns a').click(function(){

이게 bd 라는 클래스 밑에 있는 .to_sns 클래스 밑의 a 를 클릭할 때 라는 뜻이 아닌가요?

  • profile

    스케치북에서 붙여넣으셨다면 코드가 잘못되지 않을것 같은데..

    JS 파일에서 코드를 어디에다가 복사해으셨는지?

    read.html 파일에 코드를 붙여넣었는데 에러는 어떻게 나오나요?

    정상적인 코드가 작동이 안되는 이유를 물으시면 다른분들도 코드만 보다 눈아퍼요. 

     

    스케치북에서 bd라는것이 컨텐츠 부분의 클래스는 맞지만

    코드에서 의미하는 bd는 컨텐츠부분의 bd클래스 객체를 담고 있는 변수를 의미합니다. 

    스케치북 소스코드에서 제일 상단에 있는 코드를 참조하세요.