eval / rack-pjax

pjax for rails and rack applications
http://rack-pjax.herokuapp.com/
MIT License
205 stars 65 forks source link

pjax call doesn't replace data-pjax div with new content #23

Open anilmuppalla opened 11 years ago

anilmuppalla commented 11 years ago

I have a index.html.erb (Question Controller)

def index
    @questions = Question.all

    respond_to do |format|
      format.html {render layout: false}
      format.json { render json: @questions }
    end
  end

In another View home.html.erb (StaticPageController)

<div id="test">
<a href="/questions"><img alt="attendence" 
class="img-rounded" height="60" src="/assets/marks.gif" 
width="60" /></a>
</div>

and a target div in home.html.erb

<div data-pjax>
</div>

I use pjax to grab the contents from index controller and display in the target div

In the file static_pages.js.coffee

JQuery ->
    ('#test a').pjax('[data-pjax]')

on clicking the link, it goes to a new page and does not replace the target DIV

I followed the Railcasts posted here to get till here.. what am i missing?

tobidelius commented 9 years ago

@4ni1 Pjax has change a bit since then. Put the following snippet outside doument ready (jQuery ->)

$(document).pjax('a', '#[data-pjax]')

Ohh saw the created date now :)