Javascript jQuery、Mashine、JWPlayer、无限卷轴附加“&书信电报;脚本></脚本>&引用;PHP中的标记包括文件不';行不通
首先,我将快速概述我正在努力完成的任务 我有一个PHP主页,它从mySQL数据库加载图像、文本和视频(使用JWPlayer播放),并使用砖石结构进行布局。我还使用了Infinite Scroll,它使用以下代码加载其他内容:Javascript jQuery、Mashine、JWPlayer、无限卷轴附加“&书信电报;脚本></脚本>&引用;PHP中的标记包括文件不';行不通,javascript,jquery,append,jwplayer,Javascript,Jquery,Append,Jwplayer,首先,我将快速概述我正在努力完成的任务 我有一个PHP主页,它从mySQL数据库加载图像、文本和视频(使用JWPlayer播放),并使用砖石结构进行布局。我还使用了Infinite Scroll,它使用以下代码加载其他内容: $container.masonry( 'appended', $newElems, true ); 其他内容通过名为loadMore.PHP的PHP页面加载 <nav id="page-nav"> <a href="loadMore.php?n=2"
$container.masonry( 'appended', $newElems, true );
其他内容通过名为loadMore.PHP的PHP页面加载
<nav id="page-nav">
<a href="loadMore.php?n=2"></a>
</nav>
}))
在我调用砌体之后,我添加了您推荐的代码,但它似乎遇到了一些问题,因为测试的第一个警报运行正常,但第二个测试2似乎不起作用。我还推荐了隐藏图像和视频路径的代码,因为出于某种原因,它似乎阻止了通过loadMore.php加载其他内容
你知道我错过了什么吗?我已经在主页顶部为JWVideo播放器添加了loadPlayerjavascript函数。也许可以在主页上创建一个加载jwplayer的函数
function loadPlayer(id, imgPath, vidPath) {
jwplayer(id).setup({
flashplayer: 'player.swf',
image: imgPath,
skin: 'images/slim.zip',
width: 250,
height: 141,
plugins: {
gapro: { accountid: 'UA-30548455-1'}
},
file: vidPath
});
}
按如下方式返回HTML:
<div class="content-container">
<div class="content-imgpath">path name here</div>
<div class="content-vidpath">vid path here</div>
<div class="content-id" id='$i'>Loading the video player ...</div>
</div>
调用后,请执行以下操作:
$($newElems).find("div.content-container").each( function() {
var imgpath = $(this).find("div.content-imgpath").text();
var vidpath = $(this).find("div.content-vidpath").text();
var id = $(this).find("div.content-id").attr("id");
loadPlayer( id, imgpath, vidpath );
});
更新:修复了上面的变量名…Hi jwatts-感谢您的巧妙解决方案!我试图实施你的建议,我有一种感觉,它将工作,但我想我一定是错过了什么。。。返回带有div标记、图像和视频路径的HTML代码的代码工作得很好,但出于某种原因,javascript$($newElems).find(“div.content-container”)…
似乎不起作用。我将在编辑原始问题的基础上,向您详细展示我的代码…我想我已经解决了!与loadPlayer函数一起传递的变量'imgPath'和'vidPath'的大写字母为'P',但在上面定义时,它们是小写字母!它工作得很好!非常感谢!!!
<div class="content-container">
<div class="content-imgpath">path name here</div>
<div class="content-vidpath">vid path here</div>
<div class="content-id" id='$i'>Loading the video player ...</div>
</div>
div.content-imgpath, div.content-vidpath {
display: none;
}
$($newElems).find("div.content-container").each( function() {
var imgpath = $(this).find("div.content-imgpath").text();
var vidpath = $(this).find("div.content-vidpath").text();
var id = $(this).find("div.content-id").attr("id");
loadPlayer( id, imgpath, vidpath );
});