Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Added e.stopImmediatePropagation(); #51

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

Conversation

jinomb
Copy link

@jinomb jinomb commented Dec 4, 2019

Added e.stopImmediatePropagation(); to stop click event from triggering twice.

Added e.stopImmediatePropagation(); to stop click event from triggering twice.
@mgibbs189
Copy link
Owner

@mbmukesh Thanks for the PR.

Could you elaborate on the specific issue you ran into? E.g. Did you have 2 instances of the fSelect library on the page? Were some other libraries triggering their own document.click events?

I ask because e.stopImmediatePropagation() could cause more problems, especially the 2nd instance in the PR

@jinomb
Copy link
Author

jinomb commented Dec 4, 2019

:) I have a single instance that was loaded over the bootstrap modal window. As the pop up is opened every second-time fselect failed to open. The reason which I noticed is the click event was firing more than once. So, When the $(document).on('click', function(e) { event is fired more than once the condition fails which makes the code run into closeDropdown($wrap); the second time as the hidden class is removed. Adding e.stopImmediatePropagation() stopped the issue.

@mgibbs189
Copy link
Owner

The problem with adding e.stopImmediatePropagation() into $(document).on('click', function(e) {} is that it'll break any other libraries that add click handlers into document.

I have a single instance that was loaded over the bootstrap modal window

Tell me more about this. Is the <script> tag within the modal too, or is it elsewhere? And do the events only trigger twice, or does the count increase along with the number of modal opens?

@jinomb
Copy link
Author

jinomb commented Dec 4, 2019

There is a single modal and the script tag is within the modal. the content of the modal is loaded with jquery load. each time the modal is opened its fresh content without duplication of the script. the event triggers multiple times on a single click on the dropdown (event bubbling issue in jquery).

@s85251
Copy link

s85251 commented Dec 16, 2019

I have this problem, but the search input will disappear if used ?

@luyi1994
Copy link

luyi1994 commented Jul 9, 2020

I have a static box, and then click on the page for the first time to pull down multiple selection to take effect. What is the problem of multi selection invalidation after clicking this static box the second time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants