rack-pjax icon indicating copy to clipboard operation
rack-pjax copied to clipboard

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

Open anilmuppalla opened this issue 12 years ago • 1 comments

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?

anilmuppalla avatar Jun 27 '13 22:06 anilmuppalla

@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 :)

tobidelius avatar Dec 19 '14 12:12 tobidelius