Sha256: cf2ad4a3d76a201361957d6216e04db0db2abaf78dfa886c0c35ba8e44966321
Contents?: true
Size: 881 Bytes
Versions: 4
Compression:
Stored size: 881 Bytes
Contents
module Pjax extend ActiveSupport::Concern included do layout ->(c) { pjax_request? ? false : 'application' } helper_method :pjax_request? end private def redirect_pjax_to(action, url = nil) new_url = url_for(url ? url : { action: action }) render js: <<-EJS if (!window.history || !window.history.pushState) { window.location.href = '#{new_url}'; } else { $('[data-pjax-container]').html(#{render_to_string("#{action}.html.erb", layout: false).to_json}); $(document).trigger('end.pjax'); var title = $.trim($('[data-pjax-container]').find('title').remove().text()); if (title) document.title = title; window.history.pushState({}, document.title, '#{new_url}'); } EJS end def pjax_request? env['HTTP_X_PJAX'].present? end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pjax_rails-0.1.10 | ./lib/pjax.rb |
pjax_rails-0.1.9 | ./lib/pjax.rb |
pjax_rails-0.1.8 | ./lib/pjax.rb |
pjax_rails-0.1.7 | ./lib/pjax.rb |