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

Ensure the bbox input is in the correct form #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markstuart
Copy link

In our particular customisation of CKAN we have 2 forms with the class of 'search-form', and this class is used to ensure styling consistency.

With the way this was set up before, both forms were getting a ext_bbox input injected into them, but then only the first one on the page was getting the bbox value set on it. This unfortunately was not the search form that actually needed the bbox value.

With these changes, I'm trying to scope the ext_bbox input to only the actual dataset search form.

In general, I think actions like this should try to target elements by ID's where possible, rather than using classes, which should be used more for defining styling to be applied to that class, but unsure what the CKAN team preferences are on this.

});
// Add necessary field to the search form if not already created
if ($("#" + bbox_input_id).length === 0) {
$('<input type="hidden" />').attr({'id': bbox_input_id, 'name': bbox_input_id}).appendTo(form);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the form was actually 2 forms in our case due to the jquery lookup by class, the appendTo(form) was adding the hidden input to both forms. Then the later lookup and value setting ($('#ext_bbox').val) only found the first input on the page with that ID and set the val on that. Not the right form in this case.

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

Successfully merging this pull request may close these issues.

None yet

1 participant