render_async 2.1.10 β 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.all-contributorsrc +2 -1
- data/README.md +15 -1
- data/app/views/render_async/_render_async.html.erb +1 -0
- data/app/views/render_async/_request_jquery.js.erb +10 -2
- data/app/views/render_async/_request_vanilla.js.erb +11 -3
- data/lib/render_async/version.rb +1 -1
- data/lib/render_async/view_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eb3554f389bd0bcab8944c56c59238359d1c181c7dbc212d12e0335a9960fa6
|
4
|
+
data.tar.gz: a00cfb7925232e67825579356c33707d97258d369d41d92f676077c6e0b1d17e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acd95e67267622528c723d41ba5dfe1114319173f3455004523fd0dab784d8626a21314a389373f473d5147465e29773defb75c40d7ff6cb15053b7eba44e1a2
|
7
|
+
data.tar.gz: ccb2a071554bdca88a02b8b3b178711b01d116067eda7d48f01385056459cd3f59e8561d489ce76380be26ad8979398f40300759915c07962899aef608751e24
|
data/.all-contributorsrc
CHANGED
data/README.md
CHANGED
@@ -402,6 +402,20 @@ Here is an example on how to get `retryCount`:
|
|
402
402
|
</script>
|
403
403
|
```
|
404
404
|
|
405
|
+
If you need to pass retry count to the backend, you can pass `retry_count_header` in `render_async`'s options:
|
406
|
+
|
407
|
+
```erb
|
408
|
+
<%= render_async users_path,
|
409
|
+
retry_count: 5,
|
410
|
+
retry_count_header: 'Retry-Count-Current' %>
|
411
|
+
```
|
412
|
+
|
413
|
+
And then in controller you can read the value from request headers.
|
414
|
+
|
415
|
+
```
|
416
|
+
request.headers['Retry-Count-Current']&.to_i
|
417
|
+
```
|
418
|
+
|
405
419
|
### Toggle event
|
406
420
|
|
407
421
|
You can trigger `render_async` loading by clicking or doing another event to a
|
@@ -794,7 +808,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
|
|
794
808
|
<!-- prettier-ignore -->
|
795
809
|
| [<img src="https://avatars2.githubusercontent.com/u/3028124?v=4" width="100px;"/><br /><sub><b>Nikola Δuza</b></sub>](https://nikolalsvk.github.io)<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") |
|
796
810
|
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
797
|
-
| [<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") |
|
811
|
+
| [<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") [π](https://github.com/renderedtext/render_async/commits?author=reneklacan "Documentation") |
|
798
812
|
| [<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") | [<img src="https://avatars0.githubusercontent.com/u/6081795?v=4" width="100px;"/><br /><sub><b>Khoa Nguyen</b></sub>](https://github.com/ThanhKhoaIT)<br />[π»](https://github.com/renderedtext/render_async/commits?author=ThanhKhoaIT "Code") [π](https://github.com/renderedtext/render_async/commits?author=ThanhKhoaIT "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/8645918?v=4" width="100px;"/><br /><sub><b>Preet Sethi</b></sub>](https://www.linkedin.com/in/preetsethila/)<br />[π»](https://github.com/renderedtext/render_async/commits?author=preetsethi "Code") | [<img src="https://avatars3.githubusercontent.com/u/11586335?v=4" width="100px;"/><br /><sub><b>fangxing</b></sub>](https://github.com/fffx)<br />[π»](https://github.com/renderedtext/render_async/commits?author=fffx "Code") | [<img src="https://avatars3.githubusercontent.com/u/1191418?v=4" width="100px;"/><br /><sub><b>Emmanuel Pire</b></sub>](http://blog.lipsumarium.com)<br />[π»](https://github.com/renderedtext/render_async/commits?author=lipsumar "Code") [π](https://github.com/renderedtext/render_async/commits?author=lipsumar "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/615509?v=4" width="100px;"/><br /><sub><b>Maxim Geerinck</b></sub>](https://github.com/maximgeerinck)<br />[π»](https://github.com/renderedtext/render_async/commits?author=maximgeerinck "Code") | [<img src="https://avatars1.githubusercontent.com/u/251706?v=4" width="100px;"/><br /><sub><b>Don</b></sub>](https://github.com/vanboom)<br />[π»](https://github.com/renderedtext/render_async/commits?author=vanboom "Code") |
|
799
813
|
| [<img src="https://avatars0.githubusercontent.com/u/998682?v=4" width="100px;"/><br /><sub><b>villu164</b></sub>](https://github.com/villu164)<br />[π](https://github.com/renderedtext/render_async/commits?author=villu164 "Documentation") | [<img src="https://avatars.githubusercontent.com/u/11203679?v=4" width="100px;"/><br /><sub><b>Mitchell Buckley</b></sub>](https://github.com/Mbuckley0)<br />[π»](https://github.com/renderedtext/render_async/commits?author=Mbuckley0 "Code") [π](https://github.com/renderedtext/render_async/commits?author=Mbuckley0 "Documentation") | [<img src="https://avatars.githubusercontent.com/u/15371677?v=4" width="100px;"/><br /><sub><b>yhirano55</b></sub>](https://github.com/yhirano55)<br />[π»](https://github.com/renderedtext/render_async/commits?author=yhirano55 "Code") [π](https://github.com/renderedtext/render_async/commits?author=yhirano55 "Documentation") |
|
800
814
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
@@ -39,9 +39,15 @@ if (window.jQuery) {
|
|
39
39
|
|
40
40
|
function _makeRequest(currentRetryCount) {
|
41
41
|
var headers = <%= headers.to_json.html_safe %>;
|
42
|
-
var csrfTokenElement = document.querySelector('meta[name="csrf-token"]')
|
42
|
+
var csrfTokenElement = document.querySelector('meta[name="csrf-token"]');
|
43
43
|
if (csrfTokenElement)
|
44
|
-
headers['X-CSRF-Token'] = csrfTokenElement.content
|
44
|
+
headers['X-CSRF-Token'] = csrfTokenElement.content;
|
45
|
+
|
46
|
+
<% if retry_count_header %>
|
47
|
+
if (typeof(currentRetryCount) === 'number') {
|
48
|
+
headers['<%= retry_count_header.html_safe %>'] = currentRetryCount;
|
49
|
+
}
|
50
|
+
<% end %>
|
45
51
|
|
46
52
|
$.ajax({
|
47
53
|
url: '<%= path.html_safe %>',
|
@@ -100,6 +106,8 @@ if (window.jQuery) {
|
|
100
106
|
_makeRequest(currentRetryCount)
|
101
107
|
}, <%= retry_delay %>)
|
102
108
|
}
|
109
|
+
<% else %>
|
110
|
+
_retryMakeRequest = _makeRequest
|
103
111
|
<% end %>
|
104
112
|
|
105
113
|
function retry(currentRetryCount) {
|
@@ -46,9 +46,15 @@
|
|
46
46
|
request.open('<%= method %>', '<%= path.html_safe %>', asyncRequest);
|
47
47
|
|
48
48
|
var headers = <%= headers.to_json.html_safe %>;
|
49
|
-
var csrfTokenElement = document.querySelector('meta[name="csrf-token"]')
|
49
|
+
var csrfTokenElement = document.querySelector('meta[name="csrf-token"]');
|
50
50
|
if (csrfTokenElement)
|
51
|
-
headers['X-CSRF-Token'] = csrfTokenElement.content
|
51
|
+
headers['X-CSRF-Token'] = csrfTokenElement.content;
|
52
|
+
|
53
|
+
<% if retry_count_header %>
|
54
|
+
if (typeof(currentRetryCount) === 'number') {
|
55
|
+
headers['<%= retry_count_header.html_safe %>'] = currentRetryCount;
|
56
|
+
}
|
57
|
+
<% end %>
|
52
58
|
|
53
59
|
Object.keys(headers).map(function(key) {
|
54
60
|
request.setRequestHeader(key, headers[key]);
|
@@ -108,11 +114,13 @@
|
|
108
114
|
<% if retry_count > 0 %>
|
109
115
|
|
110
116
|
<% if retry_delay %>
|
111
|
-
_retryMakeRequest = function(currentRetryCount) {
|
117
|
+
var _retryMakeRequest = function(currentRetryCount) {
|
112
118
|
setTimeout(function() {
|
113
119
|
_makeRequest(currentRetryCount)
|
114
120
|
}, <%= retry_delay %>)
|
115
121
|
}
|
122
|
+
<% else %>
|
123
|
+
var _retryMakeRequest = _makeRequest
|
116
124
|
<% end %>
|
117
125
|
|
118
126
|
function retry(currentRetryCount) {
|
data/lib/render_async/version.rb
CHANGED
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.1.
|
4
|
+
version: 2.1.11
|
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: 2021-
|
12
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|