stoppropagation

ng-change in a checkbox fired more than one time, because an ng-click over it

天涯浪子 提交于 2019-12-06 04:10:36
问题 As a code is better than 1000 words, I've created a plunker in order to show my problem: http://bit.ly/1uiR2wy Given the specific DOM element, thing is that I have an input checkbox with an ng-change, I want to add an ng-click to the li that wraps it in order to be able to click in the whole area. This new ng-click makes the method in the ng-change to happens twice. And is even worse for an SPAN DESCRIPTION 2 that is happening 3 times. <li class="odd" ng-click="changeToggleModel($event)">

RxJava - How to stop (and resume) a Hot Observable (interval)?

假如想象 提交于 2019-12-05 12:56:42
I have the following Hot Observable: hotObservable = Observable.interval(0L, 1L, TimeUnit.SECONDS) .map((t) -> getCurrentTimeInMillis())) However, I can't find a good way to stop it. I was able to partially solve this using takeWhile and a boolean flag ( runTimer ): Observable.interval(0L, 1L, TimeUnit.SECONDS) .takeWhile((t) -> runTimer) .map((t) -> getCurrentTimeInMillis())) There are 2 things I don't like in this approach though: I must keep the flag runTimer around, which I don't want. Once runTimer becomes false , the Observable simply completes, which means if I want to emit again I need

Mousewheel scrolling inside container - catching events

耗尽温柔 提交于 2019-12-05 12:40:25
I have a page with inner scrollable DIV. As I hover a mouse over it and try to scroll it with mouse wheel, the contents of that DIV is scrolled as desired while the main page stays put. But when I reach the bottom of the DIV's scrolling area, whole page begin to scroll instead. I've tried to set event handlers on that div, but preventDefault() method also prevents scrolling of the DIV itself. Here comes the wrong code: $('.folderlist').on('DOMMouseScroll mousewheel', function(ev){ ev.stopPropagation(); ev.preventDefault(); }) preventDefault() prevents page scroll, but also disallows the

Prevent click event from affecting parent jquery

人走茶凉 提交于 2019-12-04 03:55:14
问题 I was to stop the event propagation from the child to the parent, i have a bunch of li tags containing a . $('li a[rel=close]').live('click', function(e){ e.stopPropagation(); e.preventDefault(); }) But it doesn;t stop the event.Any suggestions ? 回答1: stopPropagation has problems with live , from the jQuery stopPropagation docs - Since the .live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live events As Rob W has said

event.stopPropagation Not Working in Firefox

大城市里の小女人 提交于 2019-12-02 10:38:06
问题 I am building a sidebar vertical menu that contains Main Menu items and one level of sub-menu items. I am using Javascript and CSS so that when the user clicks a top-level menu item, its sub-menu items will toggle their visibility - i.e. Click a main item and its sub items will appear. Click the main item again and the sub items disappear. To avoid the sub-menu from toggling when the user clicks a sub-menu item, I used the event.stopPropagation() method. The desired result works in Chrome,

event.stopPropagation Not Working in Firefox

感情迁移 提交于 2019-12-02 06:35:06
I am building a sidebar vertical menu that contains Main Menu items and one level of sub-menu items. I am using Javascript and CSS so that when the user clicks a top-level menu item, its sub-menu items will toggle their visibility - i.e. Click a main item and its sub items will appear. Click the main item again and the sub items disappear. To avoid the sub-menu from toggling when the user clicks a sub-menu item, I used the event.stopPropagation() method. The desired result works in Chrome, Safari, and Dolphin, but does not work in Firefox 26.0 nor Android Firefox 26.0.1. If you run this

Prevent click event from affecting parent jquery

血红的双手。 提交于 2019-12-01 20:56:33
I was to stop the event propagation from the child to the parent, i have a bunch of li tags containing a . $('li a[rel=close]').live('click', function(e){ e.stopPropagation(); e.preventDefault(); }) But it doesn;t stop the event.Any suggestions ? stopPropagation has problems with live , from the jQuery stopPropagation docs - Since the .live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live events As Rob W has said your code would work fine with bind , here's a demo - http://jsfiddle.net/TmKyT/ Use .bind instead of .live

Why does preventDefault() on a parent element's click 'disable' a checkbox?

非 Y 不嫁゛ 提交于 2019-11-30 09:09:09
I encountered this situation recently (simplified here). Simply wrap a checkbox with an element and apply preventDefault() on it's click event and the checkbox becomes uncheckable. See this fiddle , but here's a snip: <div> <input type="checkbox"/> </div> /* Wrapper could be any element (and any ancestor element will work) */ $('div').on('click', function(e){ e.preventDefault(); }); /* Uncomment to make the checkbox work again $('input').on('click', function(e){ e.stopPropagation(); }); */ The behavior occurs in Chrome and FF, so I assume it is intentional. Why does the click event, which has

How to prevent event bubbling in javascript

本秂侑毒 提交于 2019-11-30 05:39:40
问题 thanks for reading... I'll get right into the issue. I have an onclick function attached to an image. <div id="mercury" onclick="displayCreations()"> Javascript function: function displayCreations(){ document.getElementById("projects").style.display = "block"; } The div I'm displaying as a block is set to none once you arrive at the page. This function sets the display to block, which works . I'm having trouble with making an onclick function for an image inside the div that sets the display

jQuery on() and stopPropagation()

早过忘川 提交于 2019-11-30 05:29:58
问题 I have a side pane that slides in from the left, adding content dynamically with get(). I want all clicks outside the pane to cause it to close by triggering a function. Based on other questions I read, I came up with the following code. $('html').click(function() { if (side_showing) { close_side(); } }); $(document).on("click", "#side", function(event) { event.stopPropagation(); }); I can't seem to make it work. I know that the on() function is being triggered, but event.stopPropagation