Open surenderrwt opened 2 years ago
Ok, that is weird. Afaik this should work.
Did you verify what $('#question_options').find('input[type="text"]').length
actually returns? (and it is what you expect?)
A suggestion: why not hide the "remove"-links (and only show them) if your threshold of minimally required questions is reached? UI/UX-wise it seems more user-friendly to hide buttons (or disable them) that you know will not work anyway.
Anyway: this suggestion does not take away the fact that the preventDefault
should work.
And you are also sure the callback is actually triggered?
yes.. the callback is working.
I had already tested this, but for demonstration purposes I have updated the demo project where this cancellation is demonstrated easily: when inserting a new task you got as in the documentation the confirmation question and on my machine this works correctly. See commit: https://github.com/nathanvda/cocoon_simple_form_demo/commit/1a45d69bf6e94a8a7deec21936147fd4fa1a1d60
So options I can think of:
Gemfile
_form.html.erb
_question_options_fields.html.erb
JS is