Questions tagged [event-delegation]
In JavaScript, event delegation is a concept of listening to specific events on some element (eg. the whole document) to catch these events being fired on any of the child elements, even the ones that did not exist when the event was being attached. This happens thanks to another concept called "event bubbling", which makes events to be visible by parent elements. Within every event handler it is possible to check what was the target element of the event.
event-delegation
336
questions
0
votes
3
answers
124
views
How to update a form-related (data-)model with every form-data change?
I have the following function, in order to update values from four different input fields:
UPDATED
My Package Class is defined as followed:
class Package {
constructor(packageID, type, weight, ...
-2
votes
3
answers
125
views
javascript removing element style after clicking other
I'm trying to remove attribute "selected" from span element when other span element (not the same div) is clicked
and
How to remove attribute "selected" of span element in ...
-2
votes
1
answer
48
views
How to prevent my dropdown's children from firing the dropdown's focusout event?
By default children inherit their parent's event listeners, whether or not the child is added after the the listener was created. This is bananas to me. I only want to add a listener to the parent ...
-1
votes
2
answers
98
views
How does one achieve the coupling of an html-element (representing a specific data-item) to its related data-item at the element's click handling?
We are displaying JOSN in a for each loop and adding the data to some html.
$.ajax({
dataType: "json",
url: 'https://***************************',
success: function (data) {
var ...
-1
votes
2
answers
142
views
How to efficiently / correctly handle the click-event at any list-item of a multiple nested list-based menu / navigation?
Sorry if my question is really for newbie level...
I have a 3 level list to build a menu, but I don't want to use href.
I would like to use a specific attribute instead and call a javascript function ...
0
votes
1
answer
53
views
How delegate events to apply my function to dynamically created cards with vanilla Java Script?
I'm trying to apply a feature that hides or shows the back of dynamically created cards when clicked (and vice versa). The first function worked, but it only applied to the template, so I found that ...
0
votes
2
answers
73
views
Stop next event listener from firing when one type of event is handled
I have 2 click listeners set up, these handle showing a modal and removing a note. These listeners use event delegation and is set up on parent container. The Note is rendered afters when users inputs ...
-1
votes
1
answer
33
views
Event delegation not working as expected when trying to remove elements in JavaScript
Sure, here's a suggestion on how you could frame your question for Stack Overflow:
Title: Event delegation not working as expected when trying to remove elements in JavaScript
Body:
I'm trying to use ...
1
vote
4
answers
170
views
How to create unobstrusive JavasScript when there are hundreds of entries
I read about unobstrusive JavaScript and how Javascript should be not explicitly placed inside HTML code.
Fine! But I have these hundreds of search results where I placed click events in the HTML ...
-1
votes
2
answers
54
views
Event delegation on non nested elements
I'm using Bootstrap group radio button on which I would like to write event delegation.
<div class="btn-group" role="group" aria-label="Basic radio toggle button group"...
3
votes
1
answer
173
views
Rails javascript delegation for tinymce-rails in a nested fields partial
Using the tinymce-rails gem in a Rails 7.1 engine, I have a form partial and a dynamically added nested fields form _page_section_fields partial, the nested fields form has a text area that makes use ...
1
vote
1
answer
81
views
Voting every given time JS
I am working on a project of a leaderboard. It is not a real thing, just a demo for learning purposes as I am a newbie.
To the point. The user can click the voting button, which will add one vote, ...
0
votes
2
answers
57
views
Cant Check Through All the Input Text Boxes for answers
I'm not sure how to go about this to try and check the user input to the answers. I have the answers set in the <input id="">, it works for the first question but doesn't work for the ...
0
votes
2
answers
87
views
How to properly check if the button pressed is correct in multiple choice quiz HTML/CSS/JavaScript
I'm wondering how to adapt this further, when I don't use All, it works for the first question. However, on the second question, the buttons don't work. Using All for some reason doesn't allow me to ...
-1
votes
3
answers
114
views
Remove Item from shopping cart does not work
REMOVE button does not work. Even in console when i click the button nothing appears in the console. Can anyone spot the problem?
I feel like something is wrong with the classes, not sure though.
This ...