Drupal.formBuilder.clickField should not require that the configure link be a descendant of the first child of the wrapper. Right now it works because the default theming adds the form-builder-title-bar as the first child node of the wrapper. If that is not the case, the link that is selected will be incorrect.
My patch firstly grabs the wrapper by using the closest() method which navigates up the DOM tree and returns the first matching element only. Then it filters the configure links that are descendants of the wrapper to make certain that they are not descendants of two (or more) form-builder-elements. This way we can be sure that the configure link selected is the one that belongs to the element that is clicked on.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | form_builder_click_field.patch | 692 bytes | quicksketch |
| #5 | form_builder_click.patch | 875 bytes | james.elliott |
| #2 | form_builder_clickField.patch | 859 bytes | james.elliott |
| form_builder_clickField.patch | 901 bytes | james.elliott |
Comments
Comment #1
quicksketchI'd like to keep using parents(':first') instead of closest(), as at least currently it's possible use jQuery 1.3 in Drupal 6 with Form Builder but closest() does not exist in that version of jQuery.
I haven't tried this out, but couldn't you use a :not() filter with a selector rather than doing another selector for
.form-builder-element .form-builder-element aelements?Comment #2
james.elliott commentedI've rerolled this against HEAD with your feedback.
Comment #3
quicksketchThis patch looks good but I'll need to do some testing before committing. Looks like it could have some issues when a field is nested inside of multiple fieldsets (and thus multiple form-builder-elements).
Comment #4
james.elliott commentedI'm pretty sure that the find() method's context will prevent the ".form-builder-element .form-builder-element a" selector from not working correctly with multiple fieldsets.
Comment #5
james.elliott commentedYou were right to be concerned with this patch. The :not() selector wasn't functioning properly in the most recent patch. Form items nested within fieldsets were causing JS errors.
I've altered my patch to fix this issue.
Comment #6
quicksketchThanks finally committed. Comment changes and prefixing the wrapper variable with $ for consistency. Applied to both branches.