简体   繁体   中英

unexpected indentation in coffee rails?

I am trying to make infinite scrolling in rails using will_paginate and coffee and after i have made the code it gave me this error ?

I USE ATOM ATOM AS MY IDE ....... <<<<<

Showing C:/Users/more/Desktop/railsapp/app/views/layouts/application.html.erb where line #6 raised:

    SyntaxError: [stdin]:7:1: unexpected indentation

my posts.coffee

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
  if $('#infinite-scrolling').size() > 0
    $(window).on 'scroll', ->
      more_posts_url = $('.pagination .next_page a').attr('href')
        if more_posts_url && $(window).scrollTop() > $(document).height() - $(window).height() - 60
            $('.pagination').html('<p> loading <p>')
            $.getScript more_posts_url
        return
      return

You have one extra indentation block after the more_posts_url variable:

if $('#infinite-scrolling').size() > 0
  $(window).on 'scroll', ->
    more_posts_url = $('.pagination .next_page a').attr('href')
    if more_posts_url && $(window).scrollTop() > $(document).height() - $(window).height() - 60
      $('.pagination').html('<p> loading <p>')
      $.getScript more_posts_url
    return
  return

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM