event-delegation

How to stop event bubbling with jquery live?

假如想象 提交于 2019-11-27 02:58:32
I am trying to stop some events but stopPropagation does not work with "live" so I am not sure what to do. I found this on their site. Live events do not bubble in the traditional manner and cannot be stopped using stopPropagation or stopImmediatePropagation. For example, take the case of two click events - one bound to "li" and another "li a". Should a click occur on the inner anchor BOTH events will be triggered. This is because when a $("li").bind("click", fn); is bound you're actually saying "Whenever a click event occurs on an LI element - or inside an LI element - trigger this click

JavaScript: How to simulate change event in internet explorer (delegation)

ⅰ亾dé卋堺 提交于 2019-11-27 02:08:36
UPDATE: (recap, fiddle and bounty) This question hasn't been getting too much attention, so I'm going to spend some rep on it. I know I tend to be overly verbose in both my answers and questions. That's why I went ahead and set up this fiddle , which is, in my view, a decent representation of the kind of code I'm currently having to use to come close to a bubbling change event. A couple of issues I'm trying to resolve: The pseudo-change event doesn't fire on a select element, unless it looses focus. In some cases the client should be redirected upon selecting a new value. How do I achieve this

Vanilla JS event delegation - dealing with child elements of the target element

喜夏-厌秋 提交于 2019-11-26 18:18:21
问题 I'm trying to do event delegation in vanilla JS. I have a button inside a container like this <div id="quiz"> <button id="game-again" class="game-again"><span class="icon-spinner icon"></span><span>Go again</span></button> </div> And following David Walsh's nice instructions I'm adding an event handler to an ancestor of the button like so: this.container.addEventListener('click', function(e){ if (e.target && e.target.id == 'game-again') { e.stopPropagation(); self.publish('primo:evento'); } }

event delegation vs direct binding when adding complex elements to a page

元气小坏坏 提交于 2019-11-26 13:28:52
I have some markup like this (classes are just for explication): <ol id="root" class="sortable"> <li> <header class="show-after-collapse">Top-Line Info</header> <section class="hide-after-collapse"> <ol class="sortable-connected"> <li> <header class="show-after-collapse">Top-Line Info</header> <section class="hide-after-collapse"> <div>Content A</div> </section> </li> </ol> </section> </li> <li> <header/> <section class="hide-after-collapse"> <ol class="sortable-connected"> <li> <header/> <section class="hide-after-collapse"> <div>Content B</div> </section> </li> </ol> </section> </li> </ol>

How to stop event bubbling with jquery live?

时光怂恿深爱的人放手 提交于 2019-11-26 12:36:40
问题 I am trying to stop some events but stopPropagation does not work with \"live\" so I am not sure what to do. I found this on their site. Live events do not bubble in the traditional manner and cannot be stopped using stopPropagation or stopImmediatePropagation. For example, take the case of two click events - one bound to \"li\" and another \"li a\". Should a click occur on the inner anchor BOTH events will be triggered. This is because when a $(\"li\").bind(\"click\", fn); is bound you\'re

event delegation vs direct binding when adding complex elements to a page

心不动则不痛 提交于 2019-11-26 03:41:40
问题 I have some markup like this (classes are just for explication): <ol id=\"root\" class=\"sortable\"> <li> <header class=\"show-after-collapse\">Top-Line Info</header> <section class=\"hide-after-collapse\"> <ol class=\"sortable-connected\"> <li> <header class=\"show-after-collapse\">Top-Line Info</header> <section class=\"hide-after-collapse\"> <div>Content A</div> </section> </li> </ol> </section> </li> <li> <header/> <section class=\"hide-after-collapse\"> <ol class=\"sortable-connected\">

What is DOM Event delegation?

こ雲淡風輕ζ 提交于 2019-11-26 01:17:45
问题 Can anyone please explain event delegation in JavaScript and how is it useful? 回答1: DOM event delegation is a mechanism of responding to ui-events via a single common parent rather than each child, through the magic of event "bubbling" (aka event propagation). When an event is triggered on an element, the following occurs: The event is dispatched to its target EventTarget and any event listeners found there are triggered. Bubbling events will then trigger any additional event listeners found

Delegation: EventEmitter or Observable in Angular

ぃ、小莉子 提交于 2019-11-25 21:47:28
问题 I am trying to implement something like a delegation pattern in Angular. When the user clicks on a nav-item , I would like to call a function which then emits an event which should in turn be handled by some other component listening for the event. Here is the scenario: I have a Navigation component: import {Component, Output, EventEmitter} from \'angular2/core\'; @Component({ // other properties left out for brevity events : [\'navchange\'], template:` <div class=\"nav-item\" (click)=\