File tree 2 files changed +8
-5
lines changed
vendor/assets/javascripts/rails_script
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
1
module RailsScript
2
- VERSION = '2.0.0 '
2
+ VERSION = '2.0.1 '
3
3
end
Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ window.App ||= {}
3
3
window .Element ||= {}
4
4
window .Utility ||= {}
5
5
6
- $ (document ).on " turbolinks:load.rails_script" , ->
6
+ # Initializer
7
+ $ (document ).on " ready.rails_script page:load.rails_script turbolinks:load.rails_script" , ->
8
+ controller = $ (' #rails-script' ).data (' controller' )
9
+ action = $ (' #rails-script' ).data (' action' )
7
10
Utility .RailsVars = $ (' #rails-script' ).data (' vars' )
8
- window .$this = new (App[" #{ $ (' #rails-script' ).data (' controller' )} " ] || App .Base )()
9
11
10
- action = $ ( ' #rails-script ' ). data ( ' action ' )
12
+ window . $this = new (App[controller] || App . Base )( )
11
13
12
14
if typeof $this .beforeAction == ' function'
13
15
$this .beforeAction action
@@ -16,8 +18,9 @@ $(document).on "turbolinks:load.rails_script", ->
16
18
if typeof $this .afterAction == ' function'
17
19
$this .afterAction action
18
20
21
+ # Clear event handlers on navigation
19
22
RailsScript .setClearEventHandlers = ->
20
- jQuery (document ).on ' turbolinks:before-visit' , ->
23
+ jQuery (document ).on ' page:before-change turbolinks:before-visit' , ->
21
24
for element in [window , document ]
22
25
for event, handlers of (jQuery ._data (element, ' events' ) || {})
23
26
for handler in handlers
You can’t perform that action at this time.
0 commit comments