Sha256: 0f614a078e68dec598fdcc237ff9bdcec59536fb17363fa8553fec25cce39d6e

Contents?: true

Size: 890 Bytes

Versions: 50

Compression:

Stored size: 890 Bytes

Contents

# Accept
#
#= require ./beforesend
#
# Make default Accept header prefer JS.
#
# jQuery's default Accept header is just `"*/*"`, which means accept
# anything back. To make AJAX requests work nicer with Rails'
# `respond_to` block, this prioritizes JS responds over others.
#
# For an example:
#
#     respond_to do |format|
#       format.html
#       format.js
#     end
#
# Would return `html` for `"*/*"` just because its first in the list.
# Adjusting the Accept header makes it work as expected.
#
# Otherwise, if there is no `format.js`, the first responder will be used.
#
# The new Accept value is:
#
#     "*/*;q=0.5, text/javascript, application/javascript,
#      application/ecmascript, application/x-ecmascript"
#

$(document).on 'ajaxBeforeSend', (event, xhr, settings) ->
  unless settings.dataType
    xhr.setRequestHeader 'Accept', '*/*;q=0.5, ' + settings.accepts.script

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
wrgem-0.0.11 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.10 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.9 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.8 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.7 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.6 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.4 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.3 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.2 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.1 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee