我正在尝试开始使用jquery航点插拔,但是我没有得到waypoint.reached回调触发。请看我在jsfiddle上的例子:
http://jsfiddle.net/yAfhU/1/
回调函数不会执行:
$('#wrapper').delegate('.waypoint', 'waypoint.reached', function (event, direction) {
alert("test");
});发布于 2013-06-15 17:25:21
你是在哪里读到这个waypoint.reached事件的?我在the documentation或the source上找不到任何关于这方面的东西。您不能仅仅编造一个事件名称,然后期望它能自动神奇地工作。
根据the documentation的说法,您需要将处理程序作为第一个参数传递给$.waypoint
$('.waypoint').waypoint(function(direction) {
console.log("waypoint reached");
});如果还需要设置其他选项,可以将该对象作为第二个参数传递,或者只传递options对象和handler属性:
$('.waypoint').waypoint(function(direction) {
console.log("waypoint reached");
}, {
offset: 10
});
// or
$('.waypoint').waypoint({
handler: function(direction) {
console.log("waypoint reached");
},
offset: 10
});Here's a fiddle.打开您的控制台,稍微滚动一下,您应该会看到日志消息。
https://stackoverflow.com/questions/17121860
复制相似问题