Skip to content

Commit

Permalink
Document know issue about turbolinks and hotwired caching and showing…
Browse files Browse the repository at this point in the history
… multiple file elements. Fixes #134
  • Loading branch information
vipulnsward committed Mar 30, 2024
1 parent db4cba0 commit 9316f9f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,30 @@ The value will be available in the controller by `params[:post][:picture]`.

The helper is detecting the value of the `multiple` property based on the mount type in your model.

### Caching issues with Turbolinks/Hotwire

If you are facing issue, with multiple input elements being rendered due to turbolinks caching you can append this fix in the `app/javascript/application.js` to overcome this:

```
import $ from 'jquery';
$(document).on('turbolinks:before-cache', function() {
$('.uploadcare--dialog__close').trigger('click');
$('.uploadcare--dialog').remove();
$('.uploadcare--widget').remove();
});
```

Similary if you are using [Hotwire](https://hotwired.dev/) then use can you use below code:

```
import $ from 'jquery';
$(document).on('turbo:before-cache', function() {
$('.uploadcare--dialog__close').trigger('click');
$('.uploadcare--dialog').remove();
$('.uploadcare--widget').remove();
});
```

### File and Group wrappers

When you mount either Uploadcare File or Group to an attribute, this attribute is getting wrapped with
Expand Down

0 comments on commit 9316f9f

Please sign in to comment.