0

Background: Building a small app where the intention is that full page loads do not happen after initially arriving to the app. Implemented pjax_rails plugin. However create, update, and destroy actions (and anything that executes a redirect_to) cause a full page load.

Question: How can I get around this while still using pjax (and preferably still using the pjax_rails gem)? I know how the problem could be solved with ajax, but it would be much better if the whole thing could be taken care of with this pjax implementation; history, degradability, etc.

To save clarification time, these things have been done:

Gemfile

gem 'pjax_rails'

application.js (including other requires in case there's some conflict I don't know about)

//= require jquery
//= require jquery_ujs
//= require jquery.pjax
//= require twitter/bootstrap
//= require_tree .

// Explicitly specify which links have PJAX enabled.
$(function() {
  $('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])').pjax('[data-pjax-container]');
});

Also tried the following in application.js in case there's something I'm overlooking

$('a').pjax('[data-pjax-container]');

And tried

$('a').pjax('[data-pjax-container]', { timeout: 200000 });

application.html.erb

<div data-pjax-container>
  <%= yield %>
</div>
anxiety
  • 1,689
  • 16
  • 25

1 Answers1

0

While this is not a direct answer to my question, it's the solution I've taken with my app.

For any single-page app (SPA), or even an app with a decent amount of asynchronous updates, using a JavaScript framework seems to really be the way to go. For me, I went with Backbone.js; although there are a lot of other options - Knockout, Angular, Cappuccino, SproutCore, Ember, Spine.

See Why use Backbone.js?

Community
  • 1
  • 1
anxiety
  • 1,689
  • 16
  • 25