render_async 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -47
- data/app/views/render_async/_render_async.html.erb +27 -15
- data/lib/render_async/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e8f5232e6ce897923d42d8d7e13e12f2106596a
|
4
|
+
data.tar.gz: ffddc0b5d3b6844d443b2b38b3314ad42fbf2b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a3b034960837da35ba4afd002c2f7c9ea05d55cbc33a20f9b6644e965c17295a48d47156eb418d7346f0204b50e298cd60525d258c174001a382884c05b4dfe
|
7
|
+
data.tar.gz: 6a74359e25c505cdb82135fa671b966a54d41fc543e989f23e5086242de52bc6dc6ade032c647ea5abae6f1713bddbb25fae583b83241e4e7f1bd36ac826b60b
|
data/README.md
CHANGED
@@ -102,21 +102,7 @@ Rendered code in the view:
|
|
102
102
|
|
103
103
|
<script nonce="lWaaV6eYicpt+oyOfcShYINsz0b70iR+Q1mohZqNaag=">
|
104
104
|
//<![CDATA[
|
105
|
-
|
106
|
-
var request = new XMLHttpRequest();
|
107
|
-
var asyncRequest = true;
|
108
|
-
var SUCCESS = 200;
|
109
|
-
var ERROR = 400;
|
110
|
-
request.open("GET", "/users", asyncRequest);
|
111
|
-
|
112
|
-
request.onload = function() {
|
113
|
-
if (request.status >= SUCCESS && request.status < ERROR) {
|
114
|
-
document.getElementById("render_async_18b41794481507226109").outerHTML = request.responseText;
|
115
|
-
}
|
116
|
-
};
|
117
|
-
|
118
|
-
request.send();
|
119
|
-
})();
|
105
|
+
...
|
120
106
|
//]]>
|
121
107
|
</script>
|
122
108
|
```
|
@@ -142,21 +128,7 @@ Rendered code in the view:
|
|
142
128
|
|
143
129
|
<script>
|
144
130
|
//<![CDATA[
|
145
|
-
|
146
|
-
var request = new XMLHttpRequest();
|
147
|
-
var asyncRequest = true;
|
148
|
-
var SUCCESS = 200;
|
149
|
-
var ERROR = 400;
|
150
|
-
request.open("GET", "/users", asyncRequest);
|
151
|
-
|
152
|
-
request.onload = function() {
|
153
|
-
if (request.status >= SUCCESS && request.status < ERROR) {
|
154
|
-
document.getElementById("render_async_14d7ac165d1505993721").outerHTML = request.responseText;
|
155
|
-
}
|
156
|
-
};
|
157
|
-
|
158
|
-
request.send();
|
159
|
-
})();
|
131
|
+
...
|
160
132
|
//]]>
|
161
133
|
</script>
|
162
134
|
```
|
@@ -184,23 +156,9 @@ Rendered code in view:
|
|
184
156
|
|
185
157
|
<script>
|
186
158
|
//<![CDATA[
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
var SUCCESS = 200;
|
191
|
-
var ERROR = 400;
|
192
|
-
request.open("GET", "/users", asyncRequest);
|
193
|
-
|
194
|
-
request.onload = function() {
|
195
|
-
if (request.status >= SUCCESS && request.status < ERROR) {
|
196
|
-
document.getElementById("render_async_04229e7abe1507987376").outerHTML = request.responseText;
|
197
|
-
|
198
|
-
document.dispatchEvent(new Event("users-loaded"));
|
199
|
-
}
|
200
|
-
};
|
201
|
-
|
202
|
-
request.send();
|
203
|
-
})();
|
159
|
+
...
|
160
|
+
document.dispatchEvent(new Event("users-loaded"));
|
161
|
+
...
|
204
162
|
//]]>
|
205
163
|
</script>
|
206
164
|
```
|
@@ -4,25 +4,37 @@
|
|
4
4
|
|
5
5
|
<% content_for :render_async do %>
|
6
6
|
<%= javascript_tag html_options do %>
|
7
|
-
(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
var ERROR = 400;
|
12
|
-
|
13
|
-
request.open("GET", "<%= path %>", asyncRequest);
|
14
|
-
|
15
|
-
request.onload = function() {
|
16
|
-
if (request.status >= SUCCESS && request.status < ERROR) {
|
17
|
-
document.getElementById("<%= container_id %>").outerHTML = request.responseText;
|
7
|
+
if (jQuery) {
|
8
|
+
(function($){
|
9
|
+
$.ajax({ url: "<%= path %>" }).always(function(response) {
|
10
|
+
$("#<%= container_id %>").replaceWith(response);
|
18
11
|
|
19
12
|
<% if event_name.present? %>
|
20
13
|
document.dispatchEvent(new Event("<%= event_name %>"));
|
21
14
|
<% end %>
|
22
|
-
}
|
23
|
-
};
|
15
|
+
});
|
16
|
+
}(jQuery));
|
17
|
+
} else {
|
18
|
+
(function() {
|
19
|
+
var request = new XMLHttpRequest();
|
20
|
+
var asyncRequest = true;
|
21
|
+
var SUCCESS = 200;
|
22
|
+
var ERROR = 400;
|
23
|
+
|
24
|
+
request.open("GET", "<%= path %>", asyncRequest);
|
25
|
+
|
26
|
+
request.onload = function() {
|
27
|
+
if (request.status >= SUCCESS && request.status < ERROR) {
|
28
|
+
var container = document.getElementById("<%= container_id %>");
|
29
|
+
|
30
|
+
<% if event_name.present? %>
|
31
|
+
document.dispatchEvent(new Event("<%= event_name %>"));
|
32
|
+
<% end %>
|
33
|
+
}
|
34
|
+
};
|
24
35
|
|
25
|
-
|
26
|
-
|
36
|
+
request.send();
|
37
|
+
})();
|
38
|
+
}
|
27
39
|
<% end %>
|
28
40
|
<% end %>
|
data/lib/render_async/version.rb
CHANGED