2011-01-27 3 views
0

私はファンシーボックスに、アイテムがクリックされたときのユニークなページにリンクするタイトルのLIKEボタンをポップアップ表示させようとしています。すべての画像は一意の番号で識別されていますが、私はthis.idでその番号を取得しようとしていますが、何も返されません。this.id fancyboxの中

$(document).ready(function() { 
    $("a.fancybox").each(function() { 
     $(this).fancybox({ 
      'overlayShow' : true, 
      'autoDimensions': true, 
      'transitionIn' : 'elastic', 
      'transitionOut' : 'elastic', 
      'overlayColor' : '#000', 
      'overlayOpacity': 0.7, 
      'titlePosition' : 'inside', 
      'titleFormat' : function() { 
       var astring = '<span id="fb-title"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.myurl.com%2Fscript.php%3Fi%3D' + this.id + '&amp;layout=standard&amp;show_faces=false&amp;width=350&amp;action=like&amp;font=lucida+grande&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:350px; height:35px;" allowTransparency="true"></iframe></span>'; 
       return astring; 
      } 
     }); 
    }); 
}); 

答えて

1

あなたは.each関数に異なる関数内thisにアクセスしようとしているので、thisは何か他のものを指します。内部関数内で安全にアクセスできるように、thisを変数にコピーすることができます。

+0

ありがとうございます! –