Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated JSONEditor elements with Turbolinks #18

Open
vijuarez opened this issue Feb 28, 2021 · 1 comment
Open

Duplicated JSONEditor elements with Turbolinks #18

vijuarez opened this issue Feb 28, 2021 · 1 comment

Comments

@vijuarez
Copy link

Hi,

I encountered an issue when using this gem. I'm building a project with Rails 6 and Turbolinks 5.2.1, which I sadly can't share at the moment. When I enter a page with an .administrate-jsoneditor or .administrate-jsoneditor-viewer element, the editor would load correctly, but ends up generating multiple copies once I leave and revisit the page.

I suspect that Turbolinks triggers the turbolinks:load event every time I visit the page, but also keeps the modified DOM between visits, generating multiple copies of the editor after repeated visits.

image

Sorry for not preparing an example showcasing the problem, but I'm short on time. I hacked together a workaround on this fork, which solves the problem by stopping the creation of a new editor if there's already one present. My solution is not robust at all and the commits were written on a hurry, so it would be better to consider an alternative fix.

Thanks!

@ericgross
Copy link

Would it be possible to merge this? I am getting bitten by the same bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants