-
Notifications
You must be signed in to change notification settings - Fork 385
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
preventDefault issue #632
Comments
Which version of cocoon/rails/turbo are you using? In the current cocoon code (which is already pretty old) there is no Try installing the latest version of cocoon (1.2.15). |
I add a addFieldListener to make it works, with the original code, not working
to make it better I paste the diff: 40c40,47
< $(document).on('click', '.add_fields', function(e) {
---
> document.querySelectorAll('.add_fields').forEach(function(element) {
> // Correctly remove the event listener
> element.removeEventListener('click', addFieldListener);
> // Add the event listener again
> element.addEventListener('click', addFieldListener);
> });
>
> function addFieldListener(e) {
103c110
< });
---
> };
134c141,142
< var hideRemoveFields = function() {
---
>
> $(document).on("ready page:load turbolinks:load", function() {
141c149
< };
---
> });
143,147d150
< $(function() {
< hideRemoveFields();
< $(document).on('page:load turbolinks:load turbo:load', hideRemoveFields); // Turbolinks support
< });
<
150a154
> after the change, the duplications stops and works fine. |
Where are you including your javascript in the page? It seems with each navigation/load the javascript is evaluated again, with turbo this should normally not be the case. |
Im using administrate gem, they include in the top part of the layout: but after verify my installed gem of administrate I see it in the bottom part I will update to the master branch of the gem or the beta and back. |
Im using adminsitrate with nestedHasmany gem, and I got some errores for cocoon + turbo
currently I report a issue here:
nickcharlton/administrate-field-nested_has_many#81
when a Turbo page is loaded , the event is added to "Add" button , so If I navigate 10 times with turbo, when i click the add button, then 10 childs forms are created
I do a bad patch to fix that
replacing the add field event to remove the listener
and works.. someone knows if this is a normal issue?
The text was updated successfully, but these errors were encountered: