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

Event handlers are added multiple times #764

Closed
scibuff opened this issue Apr 8, 2020 · 0 comments
Closed

Event handlers are added multiple times #764

scibuff opened this issue Apr 8, 2020 · 0 comments
Assignees
Labels
Bug Next Version Issue will be dealt with in the next update

Comments

@scibuff
Copy link
Contributor

scibuff commented Apr 8, 2020

Some event handlers are not removed when the DOM element is removed/deleted (via CloseOpenBox) because they are attached to the body.

Steps to reproduce:

  1. add a simple console.log call within a "onclick" function, for example in "SwitchFunction" within productions.js
	SwitchFunction: ()=>{
		$('body').on('click', '.change-view', function(){
			console.log('click .change-view')
			... 
  1. Show & Hide the production box several times by clicking on the icon in the main menu.

  2. Click on the button to switch the view, i.e. in the English version, click on the "Group" / "Single" buttons. A single click will product numerous console entries, which means the callback is executed several times with a single click

A simple fix is to attach events to the parent element, for example, in case of HTML.Box it should be the box root. In the example code above, it should be

	SwitchFunction: ()=>{
		$('#Productions').on('click', '.change-view', function(){
			console.log('click .change-view')
			... 

This way the event handlers are properly discarded with $.remove()

Window 10
Chrome/80.0.3987.163
en9 (Jaims)
2.4.3.2 - English

@scibuff scibuff changed the title Events handler are added multiple times Event handlers are added multiple times Apr 8, 2020
@Gindi4711 Gindi4711 added the Bug label Apr 8, 2020
@osv osv self-assigned this Apr 26, 2020
@osv osv added the Next Version Issue will be dealt with in the next update label May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Next Version Issue will be dealt with in the next update
Projects
None yet
Development

No branches or pull requests

4 participants