Skip to content

Commit 8c0eaab

Browse files
author
Kevin Pheasey
committed
Updates to allow RailsScript to work with Turbolinks 5.
1 parent 7b936d2 commit 8c0eaab

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
RailsScript.config do |c|
22
# Configure name that will be used to namespace the javascript classes
3-
c.app_namespace = "App"
3+
c.app_namespace = 'App'
44
end

lib/rails_script/loader_helper.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,7 @@ module RailsScript
22
module LoaderHelper
33

44
def include_rails_script
5-
javascript_tag <<-RUBY
6-
window.Utility || (window.Utility = {});
7-
Utility.RailsVars = #{@to_javascript.nil? ? '{}' : @to_javascript.to_json};
8-
9-
(function() {
10-
window.$this = new (#{RailsScript.app_namespace}.#{ controller_path.split(/\/|_/).map(&:capitalize).join('') } || #{RailsScript.app_namespace}.Base)();
11-
if (typeof $this.beforeAction === 'function') {
12-
$this.beforeAction("#{action_name}");
13-
}
14-
if (typeof $this.#{ action_name } === 'function') {
15-
$this.#{ action_name }();
16-
}
17-
if (typeof $this.afterAction === 'function') {
18-
$this.afterAction("#{action_name}");
19-
}
20-
})();
21-
RUBY
5+
content_tag :div, nil, id: 'rails-script', data: { controller: controller_path.split(/\/|_/).map(&:capitalize).join('') }
226
end
237

248
end

lib/rails_script/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RailsScript
2-
VERSION = '0.7.0'
2+
VERSION = '1.0.0'
33
end

0 commit comments

Comments
 (0)