Optimisation: pages are displayed without layout, when called from a xhr request.

Should be useful to speed up paginations
This commit is contained in:
echarp 2018-09-02 19:10:37 +02:00
parent 69dcb84780
commit a9c5d6bc55
2 changed files with 8 additions and 1 deletions

View File

@ -6,7 +6,7 @@ $(document).on 'turbolinks:load', ->
if $('#event_start_time').val() >= $('#event_end_time').val()
$('#event_start_time').val($('#event_end_time').val())
# Quick mechanism so that the ice cube rule only appears when useful
# Quick mechanism so that the ice cube rule only appears when useful
$('#event_repeat').each ->
if $(this).val() == '0'
$('.field.rule').hide()

View File

@ -5,6 +5,8 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery prepend: true, with: :exception
layout :handle_xhr_layout
private
def set_locale
@ -26,4 +28,9 @@ class ApplicationController < ActionController::Base
def set_mailer_host
ActionMailer::Base.default_url_options[:host] = request.host_with_port
end
# If the request is an xhr, we don't render any layout
def handle_xhr_layout
request.xhr? ? false : 'application'
end
end