Jquery:railscast 114,未显示警报,这是因为它是 coffeescript 吗?
Jquery: railscast 114, alert not showing, is this because it's coffeescript?
我正在按照 railscast 教程 #114 进行无限滚动,但我不使用 coffeescript。调用警报时提供的 javascript 不起作用。这里有什么问题?谢谢。
$(document).ready(function(){
$(window).scroll ->
if $(window).scrollTop() > $(document).height() - $(window).height() - 50
alert "near bottom"
});
如果这是一个 coffeescript 问题,如何使用此代码在 jquery 中工作?
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').text("Fetching more products...")
$.getScript(url)
$(window).scroll()
我已经找出你代码中的错误尝试运行这个代码
$(document).ready(function(){
$(window).scroll(function(){
if ($(window).scrollTop() > ($(document).height() - $(window).height() - 50))
{
alert("near bottom");
}
});
});
您的 jquery 函数中存在语法错误。希望这有帮助:)
你可以检查相同的here
我正在按照 railscast 教程 #114 进行无限滚动,但我不使用 coffeescript。调用警报时提供的 javascript 不起作用。这里有什么问题?谢谢。
$(document).ready(function(){
$(window).scroll ->
if $(window).scrollTop() > $(document).height() - $(window).height() - 50
alert "near bottom"
});
如果这是一个 coffeescript 问题,如何使用此代码在 jquery 中工作?
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').text("Fetching more products...")
$.getScript(url)
$(window).scroll()
我已经找出你代码中的错误尝试运行这个代码
$(document).ready(function(){
$(window).scroll(function(){
if ($(window).scrollTop() > ($(document).height() - $(window).height() - 50))
{
alert("near bottom");
}
});
});
您的 jquery 函数中存在语法错误。希望这有帮助:)
你可以检查相同的here