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.55 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.54 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.53 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.52 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.51 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.50 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.49 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.48 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.47 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.46 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.45 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.44 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.43 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.42 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.41 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.40 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.39 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.38 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.37 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee
wrgem-0.0.35 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/accept.coffee