-
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 does not stop action #595
Comments
Just to rule out the obvious (since you provide no view code, I have to guess), some questions/tests:
So, if you write your code without the test, something like
That should block the deletion as expected and add a line in the javascript console: does that work? |
I also removed the if block and check the result. But still the sections getting removed. Also console printing the sentence above as well. |
Ah, you are using rails 6, how did you include the javascript-code? For now there is still no "official" way, and maybe some of the libraries available on npm did not support all original features? |
#555 (comment) |
Found the solution. #555 (comment) is working fine. Thanks |
Great you got it working. Nice. 👍 👍 Also I was myself also busy getting it to work in a rails 6 project, so I just released the js on npm, so now you also could just do something like
and then add |
I have the following code:
If only one .nested-fields section is on the DOM, it should prevent the removal.
The code runs and reaches event.preventDefault() and execute it. But the the last .nested-fields section get removed.
Also I have following in the Gemfile:
Ruby version: 2.7.1
Rails version: 6.0.3.2
Cocoon version: 1.2.14
The text was updated successfully, but these errors were encountered: