Javascript $(';#div';).bind(';滚动';函数({}))不工作
我在这里添加了两个代码window.scroll在我的示例中起作用,但第二个代码没有将div绑定到scroll 谁知道我做错了什么 只是想让你知道我在MeteorJSUse工作 相反(就像您对Javascript $(';#div';).bind(';滚动';函数({}))不工作,javascript,jquery,meteor,bind,Javascript,Jquery,Meteor,Bind,我在这里添加了两个代码window.scroll在我的示例中起作用,但第二个代码没有将div绑定到scroll 谁知道我做错了什么 只是想让你知道我在MeteorJSUse工作 相反(就像您对窗口所做的那样) 这就是滚动()的目的 使用 相反(就像您对窗口所做的那样) 这就是滚动()的目的 试试这个- $(document).ready(function(){ $('#playlist').on('scroll',function(){ console.log('Scrolling.
窗口所做的那样)
这就是滚动()的目的 使用
相反(就像您对窗口所做的那样)
这就是滚动()的目的 试试这个-
$(document).ready(function(){
$('#playlist').on('scroll',function(){
console.log('Scrolling...');
});
});
试试这个-
$(document).ready(function(){
$('#playlist').on('scroll',function(){
console.log('Scrolling...');
});
});
如果元素已滚动,则在该元素上触发滚动事件。因此,如果只滚动DOM的“body”元素,则不会触发播放列表。
因此,您在#playlist的container元素中添加了一个滚动条。拍摄答案,降低高度并添加滚动条,然后事件将在其上触发
我做了一件事
如果元素已滚动,则在该元素上触发滚动事件。因此,如果只滚动DOM的“body”元素,则不会触发播放列表。
因此,您在#playlist的container元素中添加了一个滚动条。拍摄答案,降低高度并添加滚动条,然后事件将在其上触发
我做了一件事
使用此代码解决:
早期尝试没有结果,meteorjs项目重置后自动工作:
Template.playList.rendered = function () {
console.log("playlist rendered");
$('#playlist').on('scroll',function(){
console.log('Scrolling...');
});
}
我回答了我的问题,只要有人在寻找同样的答案
感谢所有试图帮助我的人
我爱这个社区。用以下代码解决:
早期尝试没有结果,meteorjs项目重置后自动工作:
Template.playList.rendered = function () {
console.log("playlist rendered");
$('#playlist').on('scroll',function(){
console.log('Scrolling...');
});
}
我回答了我的问题,只要有人在寻找同样的答案
感谢所有试图帮助我的人
我喜欢这个社区。你能用小提琴演示吗?哇!这是您正在使用的一些非常旧的jQuery(>3年前…)。从v1.7开始,on()
取代了bind()
方法。这就是说,这种类型的大多数问题要么是由于选择器,要么是因为元素是动态生成的,您需要使用委派事件。@Bartdude我尝试了$('#playlist')。on('scroll',function(){})@A.Wolff我没有重复的id-s,我现在将发布我的template@EhsanSajjad恐怕不行。我使用的是MeteorJS,而不仅仅是普通的html。你能在演示小提琴中重现吗?哇!这是您正在使用的一些非常旧的jQuery(>3年前…)。从v1.7开始,on()
取代了bind()
方法。这就是说,这种类型的大多数问题要么是由于选择器,要么是因为元素是动态生成的,您需要使用委派事件。@Bartdude我尝试了$('#playlist')。on('scroll',function(){})@A.Wolff我没有重复的id-s,我现在将发布我的template@EhsanSajjad恐怕不是。我使用的MeteorJS不仅仅是普通的html。.scroll()code@jp-吉忘了说我也试过了。顺便说一句,谢谢。.scroll()
的目的只是对方法.on()
进行一次简写调用,对.bind()
也是如此,所以与OP的方法没有区别code@jp-吉忘了说我也试过了。谢谢你顺便说一句。我看到这是工作,但不是对流星。js无法理解为什么。jquery的其他所有功能都正常工作,但这次不行。非常感谢。顺便说一句,我有一个滚动条。播放列表{padding:0;overflow-y:scroll;height:458px;}你在测试什么浏览器?你试过另一个吗,我最近在FF插件上遇到了一些问题。需要更多的代码输入。。。什么jquery版本,或者是Zepto或其他什么。是$(“#playlist”).length>0吗?我刚刚通过重置meteorjs解决了这个问题,我不知道为什么,但它只是自动工作。我看到这是工作,但不是在meteor.js无法理解为什么。jquery的其他所有功能都正常工作,但这次不行。非常感谢。顺便说一句,我有一个滚动条。播放列表{padding:0;overflow-y:scroll;height:458px;}你在测试什么浏览器?你试过另一个吗,我最近在FF插件上遇到了一些问题。需要更多的代码输入。。。什么jquery版本,或者是Zepto或其他什么。是$(“#playlist”).length>0吗?我刚刚通过重置meteorjs解决了这个问题,我不知道为什么,但它只是自动工作了。好的。我现在看到你的版本了。它缺少结尾分号代码>。很可能是打字错误吧?这些分号是可选的,here@VishalSMujumdar我仔细地尝试了你写的东西,但没有,它不起作用。如果这对某人不起作用,可能意味着html元素没有设置样式“overflow:hidden;”可以我现在看到你的版本了。它缺少结尾分号代码>。很可能是打字错误吧?这些分号是可选的,here@VishalSMujumdar我仔细地尝试了你写的东西,但没有,它不起作用。如果这对某人不起作用,可能意味着html元素没有设置样式“overflow:hidden;”
$( document ).ready(function (){
$('#pl_list').bind('scroll',function() {
console.log("div is scrolling");
});
})//failed
.playlist {
padding: 0;
overflow-y: scroll;
height: 458px;
}
Template.playList.rendered = function () {
console.log("playlist rendered");// i can see this on logs this tells that template is in doom
Meteor.setTimeout(function(){
$('#playlist').on('scroll',function(){
console.log('Scrolling...');
});
}, 2000);// with settimeout i have giveng it 2 more seconds
}
$('#playlist').scroll(function() {
console.log("div is scrolling");
});
$(document).ready(function(){
$('#playlist').on('scroll',function(){
console.log('Scrolling...');
});
});
html
<div id="playlist-wrapper">
<div id="playlist" class="playlist show-for-large-up">
<a href="/video/1" class="large-12 columns" id="pl1">
<div>
<div class="large-7 columns plRight">
<span>Titel</span>
</div>
</div>
</a>
body, html {
padding: 0;
margin: 0;
background-color: lightgrey;
color: #fff;
font-family: Arial;
height: 5000px;
overflow-y:scroll;
}
#stats {
position: relative;
}
#playlist-wrapper {
border: 1px solid #000;
padding: 10px;
height: 300px;
overflow-y: scroll;
}
#playlist {
height: 1000px;
background-color: darkgrey;
}
var $stats = $('#stats');
$('#playlist-wrapper').on('scroll', function() {
$stats.html('playlist scrolling');
console.log('playlist scrolling');
});
$(window).on('scroll', function() {
$stats.html('window scrolling');
console.log('window scrolling');
});
Template.playList.rendered = function () {
console.log("playlist rendered");
$('#playlist').on('scroll',function(){
console.log('Scrolling...');
});
}