Sha256: aa30cb784b86f2c65a3ebb890bd6cf70d5b228470ce50bf5817ba14b30ef7f17
Contents?: true
Size: 848 Bytes
Versions: 1
Compression:
Stored size: 848 Bytes
Contents
module Pjax extend ActiveSupport::Concern included do layout ->(c) { pjax_request? ? false : 'application' } 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pjax_rails-0.1.6 | ./lib/pjax.rb |