dom-events

Attach keyboard events to html5 canvas

[亡魂溺海] 提交于 2019-11-30 03:37:20
问题 It looks like mouse events will add listeners to canvas elements fine, but keyboard events don't seem to be working for canvas elements. Example: http://jsfiddle.net/H8Ese/1/ Browsers: Chrome 14.0 FF 5.0.1 I know I can use the document level listeners, but I'm trying to get the Canvas element first (so that your keyboard works everywhere else on the page). Any ideas on how to get key event listening working on canvas elements? 回答1: I don't think you can add keyboard event listener directly to

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

别来无恙 提交于 2019-11-30 01:44:06
Is there an event that I can tie into that is fired when a bootstrap dropdown is closed or toggled? 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 . This is how Bootstrap v2.3.2 closes the menu no matter what you click on: $('html').on('click.dropdown.data-api', function () { $el.parent().removeClass('open') }); If you're using v2.x, this could be used to know when a menu will be closed

Record and replay Javascript

我们两清 提交于 2019-11-30 00:49:50
I know it is possible to record mouse movements, scrolling and keystrokes. But what about changes to the document? How can I record changes to the document? Here is my try out. There must be a better more simple way to store all events? I am thankful for all tips I can get! <!DOCTYPE html> <html> <head> <title>Record And replay javascript</title> </head> <body id="if_no_other_id_exist"> <div style="height:100px;background:#0F0" id="test1">click me</div> <div style="height:100px;background:#9F9" class="test2">click me</div> <div style="height:100px;background:#3F9" id="test3">click me</div>

Disable hardware back button in Ionic application?

こ雲淡風輕ζ 提交于 2019-11-29 23:56:10
I'm trying to disable the back button on my Cordova app. I'm using AngularJS + Ionic Framework. I found topics about this and tried the code bellow, but it has absolutely no effect. Any idea? index.html <head> <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { document.addEventListener("backbutton", function (e) { e.preventDefault(); console.log("hello"); }, false ); } </script> </head> Note that when I push back button, I have "hello" displayed in my console. David D. Finally found the answer on this Ionic Forum thread: $ionicPlatform

React onClick - pass event with parameter

醉酒当歌 提交于 2019-11-29 22:05:54
Without Parameter function clickMe(e){ //e is the event } <button onClick={this.clickMe}></button> With Parameter function clickMe(parameter){ //how to get the "e" ? } <button onClick={() => this.clickMe(someparameter)}></button> I want to get the event . How can I get it? Try this <button onClick={(e) => { this.clickMe(e, someParameter) }}>Click Me!</button> And in your function function clickMe(event, someParameter){ //do with event } With the ES6, you can do in a shorter way like this: const clickMe = (parameter) => (event) => { // Do something } Ans use it: <button onClick={clickMe

Get ID of element that called a function

倾然丶 夕夏残阳落幕 提交于 2019-11-29 20:50:38
How can I get the ID of an element that called a JS function? body.jpg is an image of a dog as the user points his/her mouse around the screen at different parts of the body an enlarged image is shown. The ID of the area element is identical to the image filename minus the folder and extension. <div> <img src="images/body.jpg" usemap="#anatomy"/> </div> <map name="anatomy"> <area id="nose" shape="rect" coords="280,240,330,275" onmouseover="zoom()"/> </map> <script type="text/javascript"> function zoom() { document.getElementById("preview").src="images/nose.jpg"; } </script> <div> <img id=

Firefox extension to find out which Javascript event is bound to an inspected element?

不羁的心 提交于 2019-11-29 20:49:13
One can bind Javascript events to html elements without using inline declarations. Is there a way when inspecting an html element to know which events are bound to the element? I want to know about the events defined by the developer and not the internal ones that come with the browser. So if I hover over an element and a menu shows up, I want to know which method caused it. I have been trying Event Spy with the Code inspector but it logs too many of the internal ones, unless I am not using it right. NVI Visual event 2 (source: tinygrab.com ) Visual Event is an open source Javascript

Windows phone 8 touch support

删除回忆录丶 提交于 2019-11-29 20:31:33
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 the touch capabilities: http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse

AngularJS: Is ng-click “a good practice”? Why is there no ng-{event} in AngularJS?

我们两清 提交于 2019-11-29 19:51:18
I just started to learn AngularJS and struggle with some concepts of AngularJS. It would be great if somebody could explain me some points... I understand that ng-click is technically not the same as onclick (see here ), but both are placed in the markup. I thought that would be a "bad practice"? Why is this one of the core concepts of AngularJS, if most people say this is "bad"? I thought it would be better to select the DOM element from JavaScript and not to place logic in the markup. If ng-click is the right way to react to click events in AngularJS what should I do with other DOM events? I

Google Map event bounds_changed triggered multiple times when dragging

蹲街弑〆低调 提交于 2019-11-29 19:49:06
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 ? It turns out it was a reported bug: http://code.google.com/p/gmaps-api-issues/issues/detail?id=1371 . The Google team recommend to use the event "idle". For example : google.maps.event.addListener(map, 'idle