mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Throw if ujs loaded twice
I saw two posts of problem about ajax requesting twice on qiita. So I think detecting double loaded earlier make easy to find the problem. https://qiita.com/hot_study_man/items/56dc87ad734cfda68bb6 https://qiita.com/hisas/items/8399aec3a5377bf75017
This commit is contained in:
parent
0f5497499c
commit
9df747c9f0
1 changed files with 2 additions and 1 deletions
|
@ -9,7 +9,8 @@
|
||||||
} = Rails
|
} = Rails
|
||||||
|
|
||||||
# For backward compatibility
|
# For backward compatibility
|
||||||
if jQuery? and jQuery.ajax? and not jQuery.rails
|
if jQuery? and jQuery.ajax?
|
||||||
|
throw new Error('If you load both jquery_ujs and rails-ujs, use rails-ujs only.') if jQuery.rails
|
||||||
jQuery.rails = Rails
|
jQuery.rails = Rails
|
||||||
jQuery.ajaxPrefilter (options, originalOptions, xhr) ->
|
jQuery.ajaxPrefilter (options, originalOptions, xhr) ->
|
||||||
CSRFProtection(xhr) unless options.crossDomain
|
CSRFProtection(xhr) unless options.crossDomain
|
||||||
|
|
Loading…
Reference in a new issue