我希望从youtube API中提取的视频列表可以在弹出框中打开。
但是现在,当您单击图像时,它只会重定向到youtube网站。
这是相关的代码。 html.erb
<% @youtube_news.each do |item| %>
<li>
<% you_tube_presenter_for(item) do |presenter| %>
<span class="center videos">
<%= link_to image_tag(presenter.thumbnail_url), presenter.video_url, :class=> "fancyboxv" %>
</span>
<%= presenter.title %>
<span class="timestamp">
Posted <%= time_ago_in_words(presenter.published_date) %> ago
</span>
<% end %>
</li>
<% end %>
和同一页上的JS-
<script>
$(document).ready(function(){
$("a.fancyboxv").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'elastic',
'width' : '640',
'height' : '480',
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf'
'swf' :{
'wmode' :'transparent',
'allowfullscreen':'true'
}
});
return false;
});
</script>
我在这里想念什么?在此先感谢您的帮助。
最佳答案
尝试
$(document).ready(function(){
$("a.fancyboxv").click(function() {
$.fancybox({
'transitionIn' : 'none',
'transitionOut' : 'elastic',
'width' : '640',
'height' : '480',
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : 'true'
}
}); // fancybox
return false;
}); // click
}); // ready
关于ruby-on-rails - 带有Youtube API请求的Fancybox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12030760/