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

The select2 binding can be removed when used in repeating sections #192

Open
chrisala opened this issue May 10, 2023 · 2 comments
Open

The select2 binding can be removed when used in repeating sections #192

chrisala opened this issue May 10, 2023 · 2 comments

Comments

@chrisala
Copy link
Collaborator

chrisala commented May 10, 2023

This is most easily reproduced using the RLP Outcomes Report 1 and RLP Outcomes Report 2.
To reproduce:

  1. Open one of these reports
  2. Add a new investment priority if there isn't more than one.
  3. Observe the multi-select for Q 2b). At this point, both versions of 2b) may still have the correct select2 component.
  4. Enter data into one of the select 2 components
  5. Save the form and reload.

Expected:
All of the multi-selects have the select2 binding applied

Actual:
Only the final section (so the last Q2b) on the form still has the select2 binding, the other Q2b) is a regular HTML multi-select.

@chrisala
Copy link
Collaborator Author

My theory as to the cause is the jquery-validation-engine is applying the same id to all instances of the Q2b) element which causes problems with the select2 binding.
I am not currently sure why, but despite having the validation binding, the other select2 multi selects on the page don't have a jquery-validation-engine id applied so the problem with the select2 binding doesn't happen.

chrisala added a commit to AtlasOfLivingAustralia/fieldcapture that referenced this issue May 10, 2023
@chrisala
Copy link
Collaborator Author

Further investigation reveals that the cause (although the exact mechanism is unclear) is that the page attempts to validate the form when resuming a report with the "started" progress status (in order to allow the user to continue from the first invalid field).
This validation occurs before the data-binding initialisation is complete when there are pre-populations via ajax which appears to be the cause.
Adding a workaround to delay that first validation prevents this issue from happening.

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

1 participant