event-propagation

jQuery: How to stop propagation of a bound function not the entire event?

我与影子孤独终老i 提交于 2019-12-03 09:00:36
I have a click function bound to many elements. It is possible that sometimes these elements may sit within one another. So, the click event is bound to a child and also bound to its parent. The method is specific to the element clicked. Naturally, because of event bubbling, the child's event is fired first, and then the parents. I cannot have them both called at the same time because the parents event overwrites the event of the child. So I could use event.stopPropagation() so only the first element clicked receives the event. The problem is that there are other click events also attached to

jQuery cycle with pager inside div with click events - can't stop propagation

岁酱吖の 提交于 2019-12-02 10:07:21
I'm using the jQuery Isotope plugin. In each clickable (maximising/minimising) Isotope element, I'm having one jQuery Cycle slideshow generated like $('.slideshow.mainview').each(function () { var $pager = $('<div class="pager"></div>').insertAfter(this); // creates a pager for each slideshow $(this).cycle({ speed: 300, timeout: 0, pager: $pager, pagerEvent: 'click', allowPagerClickBubble: false }); }); Clicking on a pager link closes the Isotope element, so one can't see the next slide :( How can I stop pager click propagation to the parent (the Isotope element)? Any advice much appreciated!

jQuery mouseup not being detected correctly

巧了我就是萌 提交于 2019-12-02 00:57:23
问题 I have a div that contains a span. I have a mouseup, and mousedown event that should fire when pressing in the div. However it doesn't work correctly. Please go to this fiddle: http://jsfiddle.net/Ym7rM/ If you select the text and then try to drag it, it just detects the mousedown event,but not the mouseup. What am I doing wrong? I'm using Chrome. Thanks EDIT: Sorry, I simplified the question, see the new fiddle. 回答1: The mouseup event is being detected correctly; it's just that the browser

jQuery mouseup not being detected correctly

蹲街弑〆低调 提交于 2019-12-01 23:56:16
I have a div that contains a span. I have a mouseup, and mousedown event that should fire when pressing in the div. However it doesn't work correctly. Please go to this fiddle: http://jsfiddle.net/Ym7rM/ If you select the text and then try to drag it, it just detects the mousedown event,but not the mouseup. What am I doing wrong? I'm using Chrome. Thanks EDIT: Sorry, I simplified the question, see the new fiddle. The mouseup event is being detected correctly; it's just that the browser is not firing a mouseup event after you perform a drag. This is an intentional behavior by the browser. You

Excluding form fields from keypress handler assigned to body

时光怂恿深爱的人放手 提交于 2019-12-01 21:09:06
I have a keypress handler on a web page assigned to the body element. I really do want it to be active anywhere in the web page. Or so I thought. The keypress events in textual input forms also activate the body handler, which makes sense, but which I don't want. Ideally, I'd like to keep the keypress handler assigned to the body element and somehow exclude just the input forms. Is there any way I can stop the event at the input level and prevent it from propagating to body? (Or is that even the right way to look at HTML DOM events?) It would be easier simply to check which element triggered

Google Map's Double Click Event Propagation

放肆的年华 提交于 2019-11-30 11:21:16
This question is asked often, but never really answered well. Let's see if we can remedy it! Event Propagation Google allows you to bind to events in a Google Map View via their API using event handlers . Sometimes you may bind your event handler to an event that Google itself is already bound to. Thus, when your event fires and does whatever you told it to do you may find Google also doing its own little thing at the same time. Hmm, can I handle the event so my code runs, but stop the event from continuing on and firing Google's event handler? You sure can ! Welcome to Event Propagation (aka

Close Bootstrap Dropdown after link click

不羁的心 提交于 2019-11-29 10:34:31
问题 I have a bootstrap dropdown menu below. It has a link in it hooked up to a knockout.js binding, that returns false because I dont want the # tag to be send to the browser url. However doing this doesnt close the dropdown menu when I click the link. Anyway around this? HTML <div class="btn-group"> <button class="btn dropdown-toggle" data-toggle="dropdown" data-bind="enable: !noResults()"><i class="icon-download-alt" ></i> Export <span class="icon-caret-down"></span></button> <ul class=

How to continue event propagation after cancelling?

情到浓时终转凉″ 提交于 2019-11-28 21:00:30
When a user clicks a certain link I would like to present them with a confirmation dialog. If they click "Yes" I would like to continue the original navigation. One catch: my confirmation dialog is implemented by returning a jQuery.Deferred object which is resolved only when/if the user clicks the Yes button. So basically the confirmation dialog is asynchronous. So basically I want something like this: $('a.my-link').click(function(e) { e.preventDefault(); e.stopPropogation(); MyApp.confirm("Are you sure you want to navigate away?") .done(function() { //continue propogation of e }) }) Of

Event Bubbling, and Stop Propagation

孤人 提交于 2019-11-28 12:06:09
What is the difference between event.bubbles to false for any event, and setting event.stopPropagation() or stopImmediatePropagation() while handling event? I'm using Flex4 with AS3. Jason Sturges Setting bubbles to false means the event does not bubble up the display list at all. stopPropagation() and stopImmediatePropagation() make the current event listener the last to process an event. The difference between stopPropagation() and stopImmediatePropagation() is that stopImmediatePropagation() will not only prevent the event from moving to the next node, but it will also prevent any other

How to continue event propagation after cancelling?

感情迁移 提交于 2019-11-27 11:51:55
问题 When a user clicks a certain link I would like to present them with a confirmation dialog. If they click "Yes" I would like to continue the original navigation. One catch: my confirmation dialog is implemented by returning a jQuery.Deferred object which is resolved only when/if the user clicks the Yes button. So basically the confirmation dialog is asynchronous. So basically I want something like this: $('a.my-link').click(function(e) { e.preventDefault(); e.stopPropogation(); MyApp.confirm(