render_async 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: '087e733a95b08596a78b1b48ea362a5a9ae91ca6812e6f843a685d95e6823e0b'
4
- data.tar.gz: ad6763643de01af9132ae8b54ed105b5f4f0ae6c7816d30d7cbd0b680c82fd98
2
+ SHA1:
3
+ metadata.gz: a18df5b0f624707c0789dee836c5b601882dc43a
4
+ data.tar.gz: c8a83e1c667b3d7011b34cf0ff8972975be947ea
5
5
  SHA512:
6
- metadata.gz: 812f8a7872651a7074e4bad8981fd662d920ff14abe640d76671198d1d4d8e93f1c139094765dd84b13c0a7039215302555017aa1cd184f378f7979101a3f172
7
- data.tar.gz: 6dd0eddc7d00d791c36be4dffe96236314fc363659b831c7686bfeaebd8c4d364fc5c0830c835204548718e71d71048086f6964fe0fecc78749d7b3c15ea1c57
6
+ metadata.gz: 8cc1b6b04980552617706707b6d7db696b04c7701dfeafec1c2842e565c7a36c9174da124b08dd0866af4358b6fc5a7475c0fb8152335a04f4cd038c10e25edc
7
+ data.tar.gz: e9a6e58b479a343d16a7578c25894137d2f81711316100af2b4952a6e598981bbf962fbe18f91c3c3ff37ce960226bab5e82a3b289dfe2b2e8c94bce9fe446f7
@@ -14,10 +14,8 @@
14
14
  "profile": "http://nikoladjuza.me/",
15
15
  "contributions": [
16
16
  "question",
17
- "bug",
18
17
  "code",
19
18
  "doc",
20
- "example",
21
19
  "review"
22
20
  ]
23
21
  },
@@ -124,6 +122,34 @@
124
122
  "contributions": [
125
123
  "doc"
126
124
  ]
125
+ },
126
+ {
127
+ "login": "eclemens",
128
+ "name": "Jesús Eduardo Clemens Chong",
129
+ "avatar_url": "https://avatars0.githubusercontent.com/u/3135638?v=4",
130
+ "profile": "https://github.com/eclemens",
131
+ "contributions": [
132
+ "code"
133
+ ]
134
+ },
135
+ {
136
+ "login": "reneklacan",
137
+ "name": "René Klačan",
138
+ "avatar_url": "https://avatars3.githubusercontent.com/u/1935686?v=4",
139
+ "profile": "https://github.com/reneklacan",
140
+ "contributions": [
141
+ "code"
142
+ ]
143
+ },
144
+ {
145
+ "login": "gil27",
146
+ "name": "Gil Gomes",
147
+ "avatar_url": "https://avatars1.githubusercontent.com/u/1313442?v=4",
148
+ "profile": "http://gilgomes.com.br",
149
+ "contributions": [
150
+ "doc"
151
+ ]
127
152
  }
128
- ]
153
+ ],
154
+ "repoType": "github"
129
155
  }
@@ -0,0 +1,98 @@
1
+ ### 2.0.1 (2018/12/10)
2
+
3
+ * [#69](https://github.com/renderedtext/render_async/pull/69): Adding CHANGELOG.md - [@gil27](https://github.com/gil27).
4
+ * [#66](https://github.com/renderedtext/render_async/pull/66): Adding support for Turbolinks 5+ - [@eclemens](https://github.com/eclemens).
5
+ * [#65](https://github.com/renderedtext/render_async/pull/65): Invalid jQuery Promise method name - [@eclemens](https://github.com/eclemens).
6
+
7
+ ### 2.0.0 (2018/10/06)
8
+
9
+ * [#64](https://github.com/renderedtext/render_async/pull/64): Document new features - [@nikolalsvk](https://github.com/nikolalsvk).
10
+ * [#63](https://github.com/renderedtext/render_async/pull/63): Configure gem - [@nikolalsvk](https://github.com/nikolalsvk).
11
+ * [#62](https://github.com/renderedtext/render_async/pull/62): Handle request errorss - [@nikolalsvk](https://github.com/nikolalsvk).
12
+ * [#61](https://github.com/renderedtext/render_async/pull/61): Add option to pass in container_class and container_id - [@nikolalsvk](https://github.com/nikolalsvk).
13
+ * [#60](https://github.com/renderedtext/render_async/pull/60): Support event creation in IE - [@nikolalsvk](https://github.com/nikolalsvk).
14
+
15
+ ### 1.3.0 (2018/10/06)
16
+
17
+ * [#58](https://github.com/renderedtext/render_async/pull/58): Tune different method requests - [@nikolalsvk](https://github.com/nikolalsvk).
18
+ * [#52](https://github.com/renderedtext/render_async/pull/52): Configurable AJAX method, headers and body - [@reneklacan](https://github.com/reneklacan).
19
+ * [#54](https://github.com/renderedtext/render_async/pull/54): Add recipe for using with respond_to/format.js - [@filipewl](https://github.com/filipewl).
20
+ * [#50](https://github.com/renderedtext/render_async/pull/50): Add Turbolinks usage note- [@richardvenneman](https://github.com/richardvenneman).
21
+
22
+ ### 1.2.0 (2018/01/25)
23
+
24
+ * [#49](https://github.com/renderedtext/render_async/pull/49): Pass in html_element_name - [@nikolalsvk](https://github.com/nikolalsvk).
25
+ * [#48](https://github.com/renderedtext/render_async/pull/48): Move JS code to a partial - [@nikolalsvk](https://github.com/nikolalsvk).
26
+ * [#47](https://github.com/renderedtext/render_async/pull/47): Trigger request when document is ready - [@nikolalsvk](https://github.com/nikolalsvk).
27
+ * [#36](https://github.com/renderedtext/render_async/pull/36): Update README with instructions for nested async - [@SaladFork](https://github.com/SaladFork).
28
+ * [#41](https://github.com/renderedtext/render_async/pull/41): Only bother when the dom is actually ready to be changed - [@krainboltgreene](https://github.com/nikolalsvk).
29
+ * [#43](https://github.com/renderedtext/render_async/pull/43): [ci skip] Get more Open Source Helpers - [@schneems](https://github.com/schneems).
30
+ * [#42](https://github.com/renderedtext/render_async/pull/42): Integration tests - [@nikolalsvk](https://github.com/nikolalsvk).
31
+
32
+ ### 1.1.3 (2017/11/23)
33
+
34
+ * [#40](https://github.com/renderedtext/render_async/pull/40): Replace render_async's container with the response data - [@nikolalsvk](https://github.com/nikolalsvk).
35
+
36
+ ### 1.1.2 (2017/11/17)
37
+
38
+ * [#35](https://github.com/renderedtext/render_async/pull/35): Fix async without jQuery - [@SaladFork](https://github.com/SaladFork).
39
+ * [#33](https://github.com/renderedtext/render_async/pull/33): Don't html-escape the path when outputting JS - [@elsurudo](https://github.com/elsurudo).
40
+ * [#31](https://github.com/renderedtext/render_async/pull/31): Allow `render_async_cache` to take a placeholder - [@elsurudo](https://github.com/elsurudo).
41
+
42
+ ### 1.1.1 (2017/10/14)
43
+
44
+ * [#29](https://github.com/renderedtext/render_async/pull/29): Use jQuery if available - [@nikolalsvk](https://github.com/nikolalsvk).
45
+
46
+ ### 1.1.0 (2017/10/14)
47
+
48
+ * [Fix event name explanation](https://github.com/renderedtext/render_async/commit/bd1ebb7011be6868dce9da76c5db9ca1133ec71d) - [@nikolalsvk](https://github.com/nikolalsvk).
49
+ * [#22](https://github.com/renderedtext/render_async/pull/22): Dispatch JS Event when AJAX is finished- [@nikolalsvk](https://github.com/nikolalsvk).
50
+
51
+ ### 1.0.1 (2017/10/14)
52
+
53
+ * [#28](https://github.com/renderedtext/render_async/pull/28): Make vanilla JS more readable - [@nikolalsvk](https://github.com/nikolalsvk).
54
+ * [#25](https://github.com/renderedtext/render_async/pull/25): Convert to vanilla js - [@sasharevzin](https://github.com/sasharevzin).
55
+ * [#27](https://github.com/renderedtext/render_async/pull/27): Add turbolinks recipe - [@colinxfleming](https://github.com/colinxfleming).
56
+ * [#23](https://github.com/renderedtext/render_async/pull/23): Test placeholder - [@nikolalsvk](https://github.com/nikolalsvk).
57
+ * [#21](https://github.com/renderedtext/render_async/pull/21): Add specs for render_async_cache - [@nikolalsvk](https://github.com/nikolalsvk).
58
+
59
+ ### 1.0.0 (2017/09/21)
60
+
61
+ * [#20](https://github.com/renderedtext/render_async/pull/20): Rename block to placeholder - [@nikolalsvk](https://github.com/nikolalsvk).
62
+
63
+ ### 0.4.1 (2017/09/07)
64
+
65
+ * [#19](https://github.com/renderedtext/render_async/pull/19): Fix replace with - [@nikolalsvk](https://github.com/nikolalsvk).
66
+
67
+ ### 0.4.0 (2017/09/07)
68
+
69
+ * [#18](https://github.com/renderedtext/render_async/pull/18): Use replaceWith instead of html - [@nikolalsvk](https://github.com/nikolalsvk).
70
+
71
+ ### 0.3.3 (2017/09/04)
72
+
73
+ * [#17](https://github.com/renderedtext/render_async/pull/17): Prepare and test caching - [@nikolalsvk](https://github.com/nikolalsvk).
74
+ * [#16](https://github.com/renderedtext/render_async/pull/16): Improvements and fixes for cached view - [@nightsurge](https://github.com/nightsurge).
75
+ * [#15](https://github.com/renderedtext/render_async/pull/15): Add all contributors - [@nikolalsvk](https://github.com/nikolalsvk).
76
+ * [#14](https://github.com/renderedtext/render_async/pull/14): Add view caching support - [@nightsurge](https://github.com/nightsurge).
77
+
78
+ ### 0.2.3 (2017/07/11)
79
+
80
+ * [#10](https://github.com/renderedtext/render_async/pull/10): Adjust to use javascript_tag and take html_options - [@colinxfleming](https://github.com/colinxfleming).
81
+
82
+ ### 0.1.3 (2017/06/28)
83
+
84
+ * [#9](https://github.com/renderedtext/render_async/pull/9): Use commit history from kaspergrubbe/render_async - [@nikolalsvk](https://github.com/nikolalsvk).
85
+ * [#7](https://github.com/renderedtext/render_async/pull/7): Update README badges - [@nikolalsvk](https://github.com/nikolalsvk).
86
+ * [#5](https://github.com/renderedtext/render_async/pull/5): Update README.md - [@nikolalsvk](https://github.com/nikolalsvk).
87
+ * [#4](https://github.com/renderedtext/render_async/pull/4): Update installation info - [@nikolalsvk](https://github.com/nikolalsvk).
88
+ * [#3](https://github.com/renderedtext/render_async/pull/3): Allow push to rubygems.org - [@nikolalsvk](https://github.com/nikolalsvk).
89
+ * [#2](https://github.com/renderedtext/render_async/pull/2): Remove railtie and engine files - [@nikolalsvk](https://github.com/nikolalsvk).
90
+ * [#1](https://github.com/renderedtext/render_async/pull/1): Use commit history from kaspergrubbe/render_async - [@nikolalsvk](https://github.com/nikolalsvk).
91
+
92
+ ### 0.0.2 (2013/08/23)
93
+
94
+ * It is now safe to call the method render_async instead of render_asynk (Billetto namespace issue) - [@kaspergrubbe](https://github.com/kaspergrubbe)
95
+
96
+ ### 0.0.1 (2013/08/23)
97
+
98
+ * Add a webpage description to the Gemspec - [@kaspergrubbe](https://github.com/kaspergrubbe)
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Build Status](https://semaphoreci.com/api/v1/renderedtext/render_async/branches/master/shields_badge.svg)](https://semaphoreci.com/renderedtext/render_async)
2
- [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors)
2
+ [![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors)
3
3
  [![Gem Version](https://badge.fury.io/rb/render_async.svg)](https://badge.fury.io/rb/render_async)
4
4
  [![Code Climate](https://codeclimate.com/github/renderedtext/render_async/badges/gpa.svg)](https://codeclimate.com/github/renderedtext/render_async)
5
5
  [![Test Coverage](https://codeclimate.com/github/renderedtext/render_async/badges/coverage.svg)](https://codeclimate.com/github/renderedtext/render_async/coverage)
@@ -312,12 +312,27 @@ On Turbolinks applications, you may experience caching issues when navigating
312
312
  away from, and then back to, a page with a `render_async` call on it. This will
313
313
  likely show up as an empty div.
314
314
 
315
- To resolve, tell turbolinks to reload your `render_async` call as follows:
315
+ If you're using Turbolinks 5 or higher, you can resolve this by setting Turbolinks
316
+ configurtion of `render_async` to true:
317
+
318
+ ```rb
319
+ RenderAsync.configure do |config|
320
+ config.turbolinks = true # Enable this option if you are using Turbolinks 5+
321
+ end
322
+ ```
323
+
324
+ This way, you're not breaking Turbolinks flow of loading or reloading a page.
325
+ It makes it more efficient that the next option that is suggested below.
326
+
327
+ Another option:
328
+ If you want, you can tell Turbolinks to reload your `render_async` call as follows:
316
329
 
317
330
  ```erb
318
331
  <%= render_async events_path, 'data-turbolinks-track': 'reload' %>
319
332
  ```
320
333
 
334
+ This will reload the whole page with Turbolinks.
335
+
321
336
  Make sure to put `<%= content_for :render_async %>` in your base view file in
322
337
  the `<head>` and not the `<body>`.
323
338
 
@@ -388,7 +403,8 @@ You can configure it by doing the following anywhere before you call
388
403
  `render_async`:
389
404
  ```rb
390
405
  RenderAsync.configure do |config|
391
- jquery = true # This will render jQuery code, and skip Vanilla JS code
406
+ config.jquery = true # This will render jQuery code, and skip Vanilla JS code
407
+ config.turbolinks = false # Enable this option if you are using Turbolinks 5+
392
408
  end
393
409
  ```
394
410
 
@@ -417,9 +433,11 @@ The gem is available as open source under the terms of the [MIT License](http://
417
433
  Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
418
434
 
419
435
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
420
- | [<img src="https://avatars2.githubusercontent.com/u/3028124?v=4" width="100px;"/><br /><sub>Nikola Đuza</sub>](http://nikoladjuza.me/)<br />[💬](#question-nikolalsvk "Answering Questions") [🐛](https://github.com/renderedtext/render_async/issues?q=author%3Anikolalsvk "Bug reports") [💻](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Documentation") [💡](#example-nikolalsvk "Examples") [👀](#review-nikolalsvk "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3866868?v=4" width="100px;"/><br /><sub>Colin</sub>](http://www.colinxfleming.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Code") [📖](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Documentation") [💡](#example-colinxfleming "Examples") | [<img src="https://avatars2.githubusercontent.com/u/334273?v=4" width="100px;"/><br /><sub>Kasper Grubbe</sub>](http://kaspergrubbe.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=kaspergrubbe "Code") | [<img src="https://avatars2.githubusercontent.com/u/163584?v=4" width="100px;"/><br /><sub>Sai Ram Kunala</sub>](https://sairam.xyz/)<br />[📖](https://github.com/renderedtext/render_async/commits?author=sairam "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/3065882?v=4" width="100px;"/><br /><sub>Josh Arnold</sub>](https://github.com/nightsurge)<br />[💻](https://github.com/renderedtext/render_async/commits?author=nightsurge "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nightsurge "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/107798?v=4" width="100px;"/><br /><sub>Elad Shahar</sub>](https://eladshahar.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=SaladFork "Code") [💡](#example-SaladFork "Examples") | [<img src="https://avatars3.githubusercontent.com/u/232392?v=4" width="100px;"/><br /><sub>Sasha</sub>](http://www.revzin.co.il)<br />[💻](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Code") [📖](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Documentation") |
436
+ <!-- prettier-ignore -->
437
+ | [<img src="https://avatars2.githubusercontent.com/u/3028124?v=4" width="100px;"/><br /><sub><b>Nikola Đuza</b></sub>](http://nikoladjuza.me/)<br />[💬](#question-nikolalsvk "Answering Questions") [💻](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Documentation") [👀](#review-nikolalsvk "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3866868?v=4" width="100px;"/><br /><sub><b>Colin</b></sub>](http://www.colinxfleming.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Code") [📖](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Documentation") [💡](#example-colinxfleming "Examples") | [<img src="https://avatars2.githubusercontent.com/u/334273?v=4" width="100px;"/><br /><sub><b>Kasper Grubbe</b></sub>](http://kaspergrubbe.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=kaspergrubbe "Code") | [<img src="https://avatars2.githubusercontent.com/u/163584?v=4" width="100px;"/><br /><sub><b>Sai Ram Kunala</b></sub>](https://sairam.xyz/)<br />[📖](https://github.com/renderedtext/render_async/commits?author=sairam "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/3065882?v=4" width="100px;"/><br /><sub><b>Josh Arnold</b></sub>](https://github.com/nightsurge)<br />[💻](https://github.com/renderedtext/render_async/commits?author=nightsurge "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nightsurge "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/107798?v=4" width="100px;"/><br /><sub><b>Elad Shahar</b></sub>](https://eladshahar.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=SaladFork "Code") [💡](#example-SaladFork "Examples") | [<img src="https://avatars3.githubusercontent.com/u/232392?v=4" width="100px;"/><br /><sub><b>Sasha</b></sub>](http://www.revzin.co.il)<br />[💻](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Code") [📖](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Documentation") |
421
438
  | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
422
- | [<img src="https://avatars3.githubusercontent.com/u/50223?v=4" width="100px;"/><br /><sub>Ernest Surudo</sub>](http://elsurudo.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=elsurudo "Code") | [<img src="https://avatars1.githubusercontent.com/u/334809?v=4" width="100px;"/><br /><sub>Kurtis Rainbolt-Greene</sub>](https://kurtis.rainbolt-greene.online)<br />[💻](https://github.com/renderedtext/render_async/commits?author=krainboltgreene "Code") | [<img src="https://avatars2.githubusercontent.com/u/59744?v=4" width="100px;"/><br /><sub>Richard Schneeman</sub>](https://www.schneems.com)<br />[📖](https://github.com/renderedtext/render_async/commits?author=schneems "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/75705?v=4" width="100px;"/><br /><sub>Richard Venneman</sub>](https://www.cityspotters.com)<br />[📖](https://github.com/renderedtext/render_async/commits?author=richardvenneman "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/381395?v=4" width="100px;"/><br /><sub>Filipe W. Lima</sub>](https://github.com/filipewl)<br />[📖](https://github.com/renderedtext/render_async/commits?author=filipewl "Documentation") |
439
+ | [<img src="https://avatars3.githubusercontent.com/u/50223?v=4" width="100px;"/><br /><sub><b>Ernest Surudo</b></sub>](http://elsurudo.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=elsurudo "Code") | [<img src="https://avatars1.githubusercontent.com/u/334809?v=4" width="100px;"/><br /><sub><b>Kurtis Rainbolt-Greene</b></sub>](https://kurtis.rainbolt-greene.online)<br />[💻](https://github.com/renderedtext/render_async/commits?author=krainboltgreene "Code") | [<img src="https://avatars2.githubusercontent.com/u/59744?v=4" width="100px;"/><br /><sub><b>Richard Schneeman</b></sub>](https://www.schneems.com)<br />[📖](https://github.com/renderedtext/render_async/commits?author=schneems "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/75705?v=4" width="100px;"/><br /><sub><b>Richard Venneman</b></sub>](https://www.cityspotters.com)<br />[📖](https://github.com/renderedtext/render_async/commits?author=richardvenneman "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/381395?v=4" width="100px;"/><br /><sub><b>Filipe W. Lima</b></sub>](https://github.com/filipewl)<br />[📖](https://github.com/renderedtext/render_async/commits?author=filipewl "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/3135638?v=4" width="100px;"/><br /><sub><b>Jesús Eduardo Clemens Chong</b></sub>](https://github.com/eclemens)<br />[💻](https://github.com/renderedtext/render_async/commits?author=eclemens "Code") | [<img src="https://avatars3.githubusercontent.com/u/1935686?v=4" width="100px;"/><br /><sub><b>René Klačan</b></sub>](https://github.com/reneklacan)<br />[💻](https://github.com/renderedtext/render_async/commits?author=reneklacan "Code") |
440
+ | [<img src="https://avatars1.githubusercontent.com/u/1313442?v=4" width="100px;"/><br /><sub><b>Gil Gomes</b></sub>](http://gilgomes.com.br)<br />[📖](https://github.com/renderedtext/render_async/commits?author=gil27 "Documentation") |
423
441
  <!-- ALL-CONTRIBUTORS-LIST:END -->
424
442
 
425
443
  This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
@@ -17,7 +17,8 @@
17
17
  event_name: event_name,
18
18
  headers: headers,
19
19
  error_message: error_message,
20
- error_event_name: error_event_name } %>
20
+ error_event_name: error_event_name,
21
+ turbolinks: RenderAsync.configuration.turbolinks } %>
21
22
  <% else %>
22
23
  <%= render partial: 'render_async/request_vanilla',
23
24
  formats: [:js],
@@ -28,7 +29,8 @@
28
29
  event_name: event_name,
29
30
  headers: headers,
30
31
  error_message: error_message,
31
- error_event_name: error_event_name } %>
32
+ error_event_name: error_event_name,
33
+ turbolinks: RenderAsync.configuration.turbolinks } %>
32
34
  <% end %>
33
35
  <% end %>
34
36
  <% end %>
@@ -1,6 +1,12 @@
1
1
  if (window.jQuery) {
2
2
  (function($) {
3
- $(document).ready(function() {
3
+ <% if turbolinks %>
4
+ if (document.documentElement.hasAttribute("data-turbolinks-preview")) {
5
+ return;
6
+ }
7
+ <% end %>
8
+
9
+ var _listener = function() {
4
10
  var headers = <%= headers.to_json.html_safe %>;
5
11
  var csrfTokenElement = document.querySelector('meta[name="csrf-token"]')
6
12
  if (csrfTokenElement)
@@ -24,7 +30,7 @@ if (window.jQuery) {
24
30
  }
25
31
  document.dispatchEvent(event);
26
32
  <% end %>
27
- }).error(function(response) {
33
+ }).fail(function(response) {
28
34
  $("#<%= container_id %>").replaceWith('<%= error_message.try(:html_safe) %>');
29
35
 
30
36
  <% if error_event_name.present? %>
@@ -38,7 +44,13 @@ if (window.jQuery) {
38
44
  document.dispatchEvent(event);
39
45
  <% end %>
40
46
  });
41
- });
47
+ };
48
+
49
+ <% if turbolinks %>
50
+ $(document).one('turbolinks:load', _listener);
51
+ <% else %>
52
+ $(document).ready(_listener);
53
+ <% end %>
42
54
  }(jQuery));
43
55
  } else {
44
56
  console.warn("Looks like you've enabled jQuery for render_async, but jQuery is not defined");
@@ -1,5 +1,11 @@
1
1
  (function() {
2
- document.addEventListener("DOMContentLoaded", function() {
2
+ <% if turbolinks %>
3
+ if (document.documentElement.hasAttribute("data-turbolinks-preview")) {
4
+ return;
5
+ }
6
+ <% end %>
7
+
8
+ var _listener = function() {
3
9
  var request = new XMLHttpRequest();
4
10
  var asyncRequest = true;
5
11
  var SUCCESS = 200;
@@ -52,5 +58,14 @@
52
58
 
53
59
  var body = "<%= escape_javascript(data.to_s.html_safe) %>";
54
60
  request.send(body);
61
+ };
62
+
63
+ <% if turbolinks %>
64
+ document.addEventListener("turbolinks:load", function (e) {
65
+ e.target.removeEventListener(e.type, arguments.callee);
66
+ _listener.call(this);
55
67
  });
68
+ <% else %>
69
+ document.addEventListener("DOMContentLoaded", _listener);
70
+ <% end %>
56
71
  })();
@@ -1,9 +1,10 @@
1
1
  module RenderAsync
2
2
  class Configuration
3
- attr_accessor :jquery
3
+ attr_accessor :jquery, :turbolinks
4
4
 
5
5
  def initialize
6
6
  @jquery = false
7
+ @turbolinks = false
7
8
  end
8
9
  end
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module RenderAsync
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Grubbe
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-10-06 00:00:00.000000000 Z
12
+ date: 2018-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - ".gitignore"
79
79
  - ".gitmodules"
80
80
  - ".rspec"
81
+ - CHANGELOG.md
81
82
  - Gemfile
82
83
  - LICENSE
83
84
  - README.md
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  version: '0'
115
116
  requirements: []
116
117
  rubyforge_project:
117
- rubygems_version: 2.7.6
118
+ rubygems_version: 2.6.14
118
119
  signing_key:
119
120
  specification_version: 4
120
121
  summary: Render parts of the page asynchronously with AJAX