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

Prevent "Show Terms" click event from running multiple times #1602

Closed
kevinwhoffman opened this issue Apr 4, 2017 · 0 comments
Closed

Prevent "Show Terms" click event from running multiple times #1602

kevinwhoffman opened this issue Apr 4, 2017 · 0 comments
Assignees
Milestone

Comments

@kevinwhoffman
Copy link
Contributor

kevinwhoffman commented Apr 4, 2017

Issue Overview

If a Give form is on the same page twice (e.g. as an embedded form and modal form), the "Show Terms" button will slide open terms and immediately close them. This happens because the inline script is output twice and also because its selector is not specific to the form instance.

See https://github.com/WordImpress/Give/blob/master/includes/forms/template.php#L1661-L1668

Expected Behavior

Clicking "Show Terms" should only toggle terms for that form.

Current Behavior

Clicking "Show Terms" is running multiple times and toggling terms for all instances of the form on the page

Possible Solution

Two things:

  1. This script should not be output as an inline script; it should be part of the enqueued give.min.js script. As an inline script, it gets output for every instance of the form on the page, causing slideToggle to run more than once per click.

  2. The selector used to trigger slideToggle should be more specific so as to only target the terms in the same form. This could be done by using a combination of jQuery's this, parent(), and siblings().

Steps to Reproduce (for bugs)

  1. Create a form with terms.
  2. Add it to the same page twice.
  3. Click Show Terms and confirm that the terms slide open and then close immediately.
@DevinWalker DevinWalker self-assigned this Apr 4, 2017
@DevinWalker DevinWalker added this to the 1.8.6 milestone Apr 4, 2017
@ravinderk ravinderk mentioned this issue Apr 6, 2017
3 tasks
@ravinderk ravinderk self-assigned this Apr 6, 2017
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

3 participants