Skip to content

Commit fa172fa

Browse files
authored
Merge pull request #142 from renderedtext/update-turbolinks-readme
Update Turbolinks docs
2 parents fbd8401 + 0015fb0 commit fa172fa

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ And then execute:
8282
<%= render_async comment_stats_path %>
8383
```
8484
85-
2. Then create a route that will `config/routes.rb`:
85+
2. Then create a route for it `config/routes.rb`:
8686
```ruby
8787
get :comment_stats, controller: :comments
8888
```
@@ -292,7 +292,7 @@ document.addEventListener("users-loaded", function(event) {
292292
### Using default events
293293

294294
`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.
296296

297297
In case there is an error, the event `render_async_error` will fire instead.
298298

@@ -385,7 +385,7 @@ failure. In the end, if the request is still failing after 5th time, it will
385385
dispatch a [default error event](#using-default-events).
386386

387387
> :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.
389389

390390
Here is an example on how to get `retryCount`:
391391

@@ -416,7 +416,7 @@ do this by doing the following:
416416
```
417417

418418
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.
420420
The `once` option is false (`nil`) by default.
421421

422422
You can also pass in a placeholder before the `render_async` is triggered. That
@@ -461,7 +461,7 @@ loading" button.
461461
### Polling
462462

463463
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.
465465

466466
By doing this:
467467
```erb
@@ -471,8 +471,8 @@ You are telling `render_async` to fetch comments_path every 5 seconds.
471471

472472
This can be handy if you want to enable polling for a specific URL.
473473

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.
476476
> You can handle how that container element is rendered and its style by
477477
> [passing in an HTML element name](#passing-in-an-html-element-name) and
478478
> [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)
484484
feature. To do this, you can follow instructions in the
485485
[control polling with a toggle section](#control-polling-with-a-toggle).
486486

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:
489489
- 'async-stop' - this will stop polling
490490
- 'async-start' - this will start polling.
491491

@@ -523,13 +523,13 @@ An example of how you can do this looks like this:
523523
```
524524

525525
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
528528
button a user clicks.
529529

530530
### Handling errors
531531

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`
533533
and `error_event_name`.
534534

535535
- `error_message`
@@ -616,7 +616,7 @@ end
616616
```
617617

618618
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.
620620

621621
Another option:
622622
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
627627

628628
This will reload the whole page with Turbolinks.
629629

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>`.
632632
633633
### Using with Turbo
634634

@@ -646,7 +646,7 @@ end
646646
```
647647

648648
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.
650650

651651
Another option:
652652
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:
657657

658658
This will reload the whole page with Turbo.
659659

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>`.
662662
663663
### Using with respond_to and JS format
664664

@@ -677,7 +677,7 @@ def comment_stats
677677
end
678678
```
679679

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
681681
to `text/javascript`. This causes the partial not to be rendered in the HTML.
682682
This usually happens when there's browser caching.
683683

@@ -745,7 +745,7 @@ RenderAsync.configure do |config|
745745
config.turbolinks = true # Enable this option if you are using Turbolinks 5+. The default value is false.
746746
config.turbo = true # Enable this option if you are using Turbo. The default value is false.
747747
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.
749749
end
750750
```
751751

@@ -758,8 +758,8 @@ RenderAsync.configuration.jquery = true
758758
Aside from configuring whether the gem relies on jQuery or VanillaJS, you can
759759
configure other options:
760760

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.
763763
- `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.
764764
- `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.
765765

0 commit comments

Comments
 (0)