我一直在使用jQuery Docs,我正在尝试设置一个情境,其中模式的内容是从一个单独的html文件填充的。所有文件都在同一个域,同一文件夹中。到目前为止,模式将在点击时启动,但没有内容从html文件中提取。我正在使用Zurb揭示模态。
jQuery的:
$('.video-btn').click(function (e) {
e.preventDefault();
var modalUrl = $(this).attr('href');
$('#myModal').load('modalUrl #vidModal').reveal({
animationspeed: 500,
animation: 'fadeAndPop',
dismissmodalclass: 'close-reveal-modal'
});
//$('.video-wrapper').children().show();
});
链接
<a href="modal1.html" class="info-btn video-btn">
<h2>Video</h2>
<p>Cambridge at a glance</p>
</a>
/*Outer modal hidden on page*/
<div id="myModal" class="reveal-modal"></div>/*Content that is in a file named modal1.html*/
<div id="vidModal" class="reveal-modal">
<div class="inner-modal">
<div class="modal-head">
<h2>Video</h2>
<p>Cambridge at a glance</p>
<a class="close-reveal-modal"></a>
</div>
<div class="modal-share-btns"></div>
<div class="video-wrapper">
<iframe id="vid" src="http://player.vimeo.com/video/20800836?api=1" width="700" height="400" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
</div>
</div>
<!-- /inner-modal -->
</div>
答案 0 :(得分:2)
您的代码应如下所示:
$('#myModal').load(modalUrl+ ' #vidModal')
在您的代码中,您加载了网址modalUrl #vidModal
,而不是存储在与modalUrl
连接的#vidModal
中的网址
(根据评论更新)
答案 1 :(得分:1)
问题:
$('#myModal').load('modalUrl #vidModal')
modalURl
被包含在字符串文字中。
你应该这样做:
$('#myModal').load(modalUrl + ' #vidModal')