gpt4 book ai didi

jquery - meteor 以模态播放youtube视频

转载 作者:行者123 更新时间:2023-12-03 05:38:46 26 4
gpt4 key购买 nike

我正在尝试制作YouTube模态,但一切正常,但是我无法找到通过在模态外部单击来阻止它的方法。

<template name="modal">
<div class="container">
<a type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-1" id="clickMe" href="#">activate the modal</a>
<div class="modal" id="modal-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<iframe id="iframe" width="1280" height="720" src="//www.youtube.com/embed/F0naUkyEkmM" data-autoplay-src="//www.youtube.com/embed/F0naUkyEkmM?autoplay=1"></iframe>
<button class="close" type="button" data-dismiss="modal">&times;</button>
<h1 class="modal-title">this is a modal</h1>
</div>
</div>
</div>
</div>
</div>
</template>


if (Meteor.isClient) {
Template.modal.events({
'click #clickMe': function(event,template){
var vi = jQuery("#iframe");
vi.attr("src", vi.data("autoplay-src") );
}
})
};

最佳答案

现在工作!可能我的问题没有道理,但这是应该做的事情:)

  Template.modal.rendered = function() {
$('#myModal').on('show.bs.modal', function(event) {
var modal, src;
modal = $(this);
return modal.find('iframe').attr('src', src = "https://www.youtube.com/embed/AGwaa2c2o-A?showinfo=0&autoplay=1");
});
return $('#myModal').on('hide.bs.modal', function(event) {
var modal;
modal = $(this);
return modal.find('iframe').attr('src', '');
});
};
<template name="modal">
<button href="#" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg"></button>
<div class="modal fade bs-example-modal-lg" id="myModal" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title text-center" id="gridSystemModalLabel">yo wassp!</h4>
</div>
<div class="modal-body">
<iframe width="871" height="480" src="https://www.youtube.com/embed/AGwaa2c2o-A?showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
</template>

关于jquery - meteor 以模态播放youtube视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32044757/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com