dom-events

Twitter Bootstrap: Call a js function when a dropdown is closed

こ雲淡風輕ζ 提交于 2019-12-18 10:58:35
问题 Is there an event that I can tie into that is fired when a bootstrap dropdown is closed or toggled? 回答1: From twitter bootstrap official page: $('#myDropdown').on('hide.bs.dropdown', function () { // do something… }); hide.bs.dropdown is one of 4 events described here. Update (13-Apr-16) These events also work same in Bootstrap 4 . Bootstrap v4 Documentation. 回答2: This is how Bootstrap v2.3.2 closes the menu no matter what you click on: $('html').on('click.dropdown.data-api', function () {

Windows phone 8 touch support

天涯浪子 提交于 2019-12-18 10:19:41
问题 Does windows phone 8 fully support touch events within the default browser? Does it work out of the box so that arbitrary touchmove events can be detected by a web-page? I have had issues with some browsers which hijack the touchmove events to use for their interface as a swipe gesture. Does windows phone 8 browser do anything like that? Can anyone point to any documentation about windows phone 8 touch events? EDIT: There is a page here that would allow someone with a wondows phone 8 to test

Google Map event bounds_changed triggered multiple times when dragging

匆匆过客 提交于 2019-12-18 10:07:59
问题 I have a google map with markers. I want my markers to be refreshed when the map is moved/zoomed... Google recommend to use the event bounds_changed for that, but when I move the map, the event is triggered for each pixel that I move the map . I want the map to be refreshed only when the user stopped moving the map, i.e. when he released the mouse button after dragging. How can I do that ? 回答1: It turns out it was a reported bug: http://code.google.com/p/gmaps-api-issues/issues/detail?id=1371

Prevent browser scroll on HTML5 History popstate

六眼飞鱼酱① 提交于 2019-12-18 09:57:18
问题 Is it possible to prevent the default behaviour of scrolling the document when a popstate event occurs? Our site uses jQuery animated scrolling and History.js, and state changes should scroll the user around to different areas of the page whether via pushstate or popstate. The trouble is the browser restores the scroll position of the previous state automatically when a popstate event occurs. I've tried using a container element set to 100% width and height of the document and scrolling the

Events vs Streams vs Observables vs Async Iterators

蓝咒 提交于 2019-12-18 09:54:24
问题 Currently, the only stable way to process a series of async results in JavaScript is using the event system. However, three alternatives are being developed: Streams: https://streams.spec.whatwg.org Observables: https://tc39.github.io/proposal-observable Async Iterators: https://tc39.github.io/proposal-async-iteration What are the differences and benefits of each over events and the others? Do any of these intend to replace events? 回答1: There are roughly two categories of APIs here: pull and

Jquery - run function when DOM element is added

假如想象 提交于 2019-12-18 05:18:22
问题 I have a website with jQuery and jQuery UI. I have a Javascript function: function ToButton() { $(".ToButton").button(); } This function runing after the page load and change all elements with class "ToButton". Also I change HTML code when user press a button. E.g.: $("body").append('<span class="ToButton">Test Button</span>'); And I want to run ToButton function to this new element too, but live or delegate methods in jQuery don't have "show" or "create" event type. So I need call function

Override html5 validation

回眸只為那壹抹淺笑 提交于 2019-12-18 05:00:29
问题 I'm working on a simple login form, with two fields: <form> <input type="email" name="email" required /> <input type="password" name="password" required /> <button type="submit">Log in</button> </form> For modern browsers, validation is automatically triggered. However, if Javascript is available, I want to take over the html5 form validation, and handle everything myself. I want to validate automatically 'onblur' (only the affected field) and I want to validate all fields when 'submit' is

Catching event when following a link

好久不见. 提交于 2019-12-18 03:35:58
问题 I am trying to track clicks on an external link (without using a "redirect page"). How can I capture an event when a user follows a link, regardless of whether the user: Left clicks on the link Right clicks on the link and open it in a new window Use the keyboard to activate the link Is there other ways to activate a link? The onClick event only applies to the first. If setting href="javascript:fireEventAndFollowLink()" the user will not be able to open the link in a new window (2), so this

How to detect when an image has finished rendering in the browser (i.e. painted)?

老子叫甜甜 提交于 2019-12-17 23:37:05
问题 On a web app I need to work with a lot of high-res images, which are dynamically added to the DOM tree. They are pre-loaded, then added to the page. It's one thing to detect when such an image has finished loading, for this I use the load event, but how can I detect when it has finished being rendered within the browser, using Javascript? When working with high resolution images, the actual painting process can take a lot of time and it's very important to know when it ends. 回答1: I used

Javascript event delegation, handling parents of clicked elements?

自古美人都是妖i 提交于 2019-12-17 22:52:03
问题 http://jsfiddle.net/walkerneo/QqkkA/ I've seen many questions here either asking about or being answered with event delegation in javascript, but I've yet to see, however, how to use event delegation for elements that aren't going to be the targets of the click event. For example: HTML: <ul> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> </ul>​ CSS: ul{