@@ -82,7 +82,7 @@ And then execute:
82
82
<%= render_async comment_stats_path %>
83
83
```
84
84
85
- 2. Then create a route that will `config/routes.rb`:
85
+ 2. Then create a route for it `config/routes.rb`:
86
86
```ruby
87
87
get :comment_stats, controller: :comments
88
88
```
@@ -292,7 +292,7 @@ document.addEventListener("users-loaded", function(event) {
292
292
### Using default events
293
293
294
294
` render_async ` will fire the event ` render_async_load ` when an async partial
295
- has loaded and rendered on page.
295
+ has loaded and rendered on the page.
296
296
297
297
In case there is an error, the event ` render_async_error ` will fire instead.
298
298
@@ -385,7 +385,7 @@ failure. In the end, if the request is still failing after 5th time, it will
385
385
dispatch a [ default error event] ( #using-default-events ) .
386
386
387
387
> :candy : If you are catching an event after an error, you can get ` retryCount ` from
388
- the event. ` retryCount ` will have number of retries it took before the event was dispatched.
388
+ the event. ` retryCount ` will have the number of retries it took before the event was dispatched.
389
389
390
390
Here is an example on how to get ` retryCount ` :
391
391
@@ -416,7 +416,7 @@ do this by doing the following:
416
416
```
417
417
418
418
This will trigger ` render_async ` to load the ` comments_path ` when you click the ` #comments-button ` element.
419
- If you want to remove event once it's triggered, you can pass ` once: true ` in the toggle options.
419
+ If you want to remove an event once it's triggered, you can pass ` once: true ` in the toggle options.
420
420
The ` once ` option is false (` nil ` ) by default.
421
421
422
422
You can also pass in a placeholder before the ` render_async ` is triggered. That
@@ -461,7 +461,7 @@ loading" button.
461
461
### Polling
462
462
463
463
You can call ` render_async ` with interval argument. This will make render_async
464
- call specified path at specified interval.
464
+ call specified path at the specified interval.
465
465
466
466
By doing this:
467
467
``` erb
@@ -471,8 +471,8 @@ You are telling `render_async` to fetch comments_path every 5 seconds.
471
471
472
472
This can be handy if you want to enable polling for a specific URL.
473
473
474
- > :warning : By passing interval to ` render_async ` , initial container element
475
- > will remain in HTML tree, it will not be replaced with request response.
474
+ > :warning : By passing interval to ` render_async ` , the initial container element
475
+ > will remain in the HTML tree and it will not be replaced with request response.
476
476
> You can handle how that container element is rendered and its style by
477
477
> [ passing in an HTML element name] ( #passing-in-an-html-element-name ) and
478
478
> [ HTML element class] ( #passing-in-a-container-class-name ) .
@@ -484,8 +484,8 @@ First one is pretty simple, and it involves using the [toggle](#toggle-event)
484
484
feature. To do this, you can follow instructions in the
485
485
[ control polling with a toggle section] ( #control-polling-with-a-toggle ) .
486
486
487
- Second option is more advanced and it involves emitting events to the ` render_async ` 's
488
- container element. From your code, you can emit following events:
487
+ The second option is more advanced and it involves emitting events to the ` render_async ` 's
488
+ container element. From your code, you can emit the following events:
489
489
- 'async-stop' - this will stop polling
490
490
- 'async-start' - this will start polling.
491
491
@@ -523,13 +523,13 @@ An example of how you can do this looks like this:
523
523
```
524
524
525
525
We are rendering two buttons - "Stop polling" and "Start polling". Then, we
526
- attach event listener to catch any clicking on the buttons. When the buttons
527
- are clicked, we either stop the polling, or start the polling, depending which
526
+ attach an event listener to catch any clicking on the buttons. When the buttons
527
+ are clicked, we either stop the polling or start the polling, depending on which
528
528
button a user clicks.
529
529
530
530
### Handling errors
531
531
532
- ` render_async ` let's you handle errors by allowing you to pass in ` error_message `
532
+ ` render_async ` lets you handle errors by allowing you to pass in ` error_message `
533
533
and ` error_event_name ` .
534
534
535
535
- ` error_message `
616
616
```
617
617
618
618
This way, you're not breaking Turbolinks flow of loading or reloading a page.
619
- It makes it more efficient that the next option that is suggested below.
619
+ It is more efficient than the next option below.
620
620
621
621
Another option:
622
622
If you want, you can tell Turbolinks to reload your ` render_async ` call as follows:
@@ -627,8 +627,8 @@ If you want, you can tell Turbolinks to reload your `render_async` call as follo
627
627
628
628
This will reload the whole page with Turbolinks.
629
629
630
- > :bulb : Make sure to put ` <%= content_for :render_async %> ` in your base view file in
631
- the `<head > ` and not the ` <body >`.
630
+ > :bulb : If Turbolinks is misbehaving in some way, make sure to put ` <%= content_for :render_async %> ` in your base view file in
631
+ the `<body > ` and not the ` <head >`.
632
632
633
633
### Using with Turbo
634
634
646
646
```
647
647
648
648
This way, you're not breaking Turbos flow of loading or reloading a page.
649
- It makes it more efficient that the next option that is suggested below.
649
+ It is more efficient than the next option below.
650
650
651
651
Another option:
652
652
If you want, you can tell Turbo to reload your ` render_async ` call as follows:
@@ -657,8 +657,8 @@ If you want, you can tell Turbo to reload your `render_async` call as follows:
657
657
658
658
This will reload the whole page with Turbo.
659
659
660
- > :bulb : Make sure to put ` <%= content_for :render_async %> ` in your base view file in
661
- the `<head > ` and not the ` <body >`.
660
+ > :bulb : If Turbo is misbehaving in some way, make sure to put ` <%= content_for :render_async %> ` in your base view file in
661
+ the `<body > ` and not the ` <head >`.
662
662
663
663
### Using with respond_to and JS format
664
664
@@ -677,7 +677,7 @@ def comment_stats
677
677
end
678
678
```
679
679
680
- When you do this, Rails will sometime set the response's ` Content-Type ` header
680
+ When you do this, Rails will sometimes set the response's ` Content-Type ` header
681
681
to ` text/javascript ` . This causes the partial not to be rendered in the HTML.
682
682
This usually happens when there's browser caching.
683
683
@@ -745,7 +745,7 @@ RenderAsync.configure do |config|
745
745
config.turbolinks = true # Enable this option if you are using Turbolinks 5+. The default value is false.
746
746
config.turbo = true # Enable this option if you are using Turbo. The default value is false.
747
747
config.replace_container = false # Set to false if you want to keep the placeholder div element from render_async. The default value is true.
748
- config.nonces = true # Set to true if you want render_async's javascript_tag to always receive nonce: true. The default value is false.
748
+ config.nonces = true # Set to true if you want render_async's javascript_tag always to receive nonce: true. The default value is false.
749
749
end
750
750
```
751
751
@@ -758,8 +758,8 @@ RenderAsync.configuration.jquery = true
758
758
Aside from configuring whether the gem relies on jQuery or VanillaJS, you can
759
759
configure other options:
760
760
761
- - ` turbolinks ` option - If you are using Turbolinks 5+, you should enable this option since it supports Turbolinks way of loading data. The default value for this options if false.
762
- - ` turbo ` option - If you are using Turbo, you should enable this option since it supports Turbo way of loading data. The default value for this options if false.
761
+ - ` turbolinks ` option - If you are using Turbolinks 5+, you should enable this option since it supports Turbolinks way of loading data. The default value for this option is false.
762
+ - ` turbo ` option - If you are using Turbo, you should enable this option since it supports Turbo way of loading data. The default value for this option is false.
763
763
- ` replace_container ` option - If you want render_async to replace its container with the request response, turn this on. You can turn this on globally for all render_async calls, but if you use this option in a specific render_async call, it will override the global configuration. The default value is true.
764
764
- ` nonces ` - If you need to pass in ` nonce: true ` to the ` javascript_tag ` in your application, it might make sense for you to turn this on globally for all render_async calls. To read more about nonces, check out [ Rails' official guide on security] ( https://edgeguides.rubyonrails.org/security.html ) . The default value is false.
765
765
0 commit comments