Note that there are some explanatory texts on larger screens.

plurals
  1. POendless scrolling does not work
    text
    copied!<p><strong>Update: My Github Repository <a href="https://github.com/Marc585/smartforce2" rel="nofollow">https://github.com/Marc585/smartforce2</a></strong></p> <p>i just finished the onemonthrails tutorial. at the last chapter its about endless scrolling. i tripple checked my code but it just doesn't work. I don't get an error or anything. It just doesn't do anything. I'm building a pinterest clone and after i scroll to the bottom it should load the next page of pins.</p> <p>This is my pins.js.coffee</p> <pre><code># 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://jashkenas.github.com/coffee-script/ jQuery -&gt; $('#pins').imagesLoaded -&gt; $('#pins').masonry itemSelector: ".box" if $('.pagination').length $(window).scroll -&gt; url = $('.pagination .next_page a').attr('href') if url &amp;&amp; $(window).scrollTop() &gt; $(document).height() - $(window).height() - 50 # What to do at the bottom of the page $('.pagination').text("Fetching more pins...") $.getScript(url) $(window).scroll() </code></pre> <p>This is my index.js.erb</p> <pre><code>$boxes = $('&lt;%= j render(@pins) %&gt;') $('#pins').append( $boxes ).imagesLoaded( function(){ $('#pins').masonry( 'reload'); }); &lt;% if @pins.next_page %&gt; $('.pagination').replaceWith('&lt;%= j will_paginate(@pins) %&gt;'); &lt;% else %&gt; $('.pagination').remove(); &lt;% end %&gt; </code></pre> <p>This is my pins controller:</p> <pre><code>class PinsController &lt; ApplicationController before_filter :authenticate_user!, except: [:index] # GET /pins # GET /pins.json def index @pins = Pin.order("created_at desc").page(params[:page]).per_page(20) respond_to do |format| format.html # index.html.erb format.json { render json: @pins } format.js end end # GET /pins/1 # GET /pins/1.json def show @pin = Pin.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @pin } end end # GET /pins/new # GET /pins/new.json def new @pin = current_user.pins.new respond_to do |format| format.html # new.html.erb format.json { render json: @pin } end end # GET /pins/1/edit def edit @pin = current_user.pins.find(params[:id]) end # POST /pins # POST /pins.json def create @pin = current_user.pins.new(params[:pin]) respond_to do |format| if @pin.save format.html { redirect_to @pin, notice: 'Pin was successfully created.' } format.json { render json: @pin, status: :created, location: @pin } else format.html { render action: "new" } format.json { render json: @pin.errors, status: :unprocessable_entity } end end end # PUT /pins/1 # PUT /pins/1.json def update @pin = current_user.pins.find(params[:id]) respond_to do |format| if @pin.update_attributes(params[:pin]) format.html { redirect_to @pin, notice: 'Pin was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @pin.errors, status: :unprocessable_entity } end end end # DELETE /pins/1 # DELETE /pins/1.json def destroy @pin = current_user.pins.find(params[:id]) @pin.destroy respond_to do |format| format.html { redirect_to pins_url } format.json { head :no_content } end end end </code></pre> <p>Error Message from my developer tools <a href="https://www.dropbox.com/s/odqknmw7np1f4cv/Bildschirmfoto%202013-08-31%20um%2014.34.40.png" rel="nofollow">https://www.dropbox.com/s/odqknmw7np1f4cv/Bildschirmfoto%202013-08-31%20um%2014.34.40.png</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload