dom-events

Replace image element in SVG dynamically

随声附和 提交于 2019-12-22 00:47:43
问题 I would like to replace an image element of SVG tag. I want that every call to an object which holds the image in controller.js, I will take this image and represent this image as a blur background image by SVG in different file called default.js. How should I do it? default.html : <div id="backgroundImage"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <filter id="myGaussianBlur" x="0" y="0"> <feGaussianBlur in="SourceGraphic" stdDeviation="2"><

jQuery/javascript different behaviours with user click and programatically click a checkbox

北城余情 提交于 2019-12-21 20:42:32
问题 A bit hard to explain, so I've set up a jsFiddle here. Basically, I have some behaviour triggered when a user clicks a checkbox. In another place I'm trying to programatically click the check box and I need to see the exact same behaviour. It doesn't work, seemingly something to do with the order of the click and determining the checked attribute. How can I get the behaviour I'm looking for without resorting to a hack? 回答1: I tend to use change handler here instead (since jQuery normalizes

Dijit TabContainer Events - onFocus

旧城冷巷雨未停 提交于 2019-12-21 20:37:26
问题 I have a Tab Container and I want to execute some js when I click on a tab's title bar. I can't seem to figure out how to add an event to that. EDIT: It looks like I'll be using onFocus, but I'm still having trouble finding the proper syntax. EDIT: Found onFocus and onBlur, but still having trouble getting it to work. 回答1: You need to connect to the _transition event. var tabs = dijit.byId("tabs"); dojo.connect(tabs,"_transition", function(newPage, oldPage){ console.log("I was showing: ",

JavaScript Event Listeners for when the DOM changes [duplicate]

老子叫甜甜 提交于 2019-12-21 12:57:31
问题 This question already has answers here : Is there a JavaScript / jQuery DOM change listener? (5 answers) Closed 2 years ago . I'm writing a Mozilla Firefox Extension (Javascript without the BS of having to identify if it's IE or Firefox), where I find myself stuck in the following situation. On a page load, I add event listeners like so: extension.addEventListener("DOMContentLoaded", extension.onPageLoad, true); That would execute m "onPageLoad()" method as soon as the DOM is loaded, meaning

Pass parameter to callback function

白昼怎懂夜的黑 提交于 2019-12-21 07:57:31
问题 My code // do ajax request and get JSON response for (var i = 0; i < data.results.length; i++) { result = data.results[i]; // do stuff and create google maps marker marker = new google.maps.Marker({ position: new google.maps.LatLng(result.lat, result.lng), map: map, id: result.id }); google.maps.event.addListener(marker, 'click', function() { createWindow(marker.id); //<==== this doesn't work because marker always points to the last results when this function is called }); } How to solve this

How do you remove an event listener that uses “this” in TypeScript?

谁都会走 提交于 2019-12-21 07:12:09
问题 In JavaScript, for an event handler that needs access to private members and functions, I can rely on the function scope of those to be accessible within my event handler function, and do something like this: theElement.addEventListener("click", onClick); and later: theElement.removeEventListener("click", onClick); In TypeScript, I need to use an anonymous function to have this be the containing object, like so: theElement.addEventListener("click", (event) => this.onClick(event)); In this

HTML 5 drag events

偶尔善良 提交于 2019-12-21 05:13:08
问题 I am trying to build a reorderable list in JS and HTML. (trying to do it without using jQuery ui ) I can't seem to figure out why only the dragstart and dragend events fire when a list item is dragged. Anyone know why the other events not firing? <ul> <li draggable="true" class="drag">1111111</li> <li draggable="true" class="drag">222222</li> <li draggable="true" class="drag">333333</li> <li draggable="true" class="drag">444444</li> </ul> <script type="text/javascript"> var drags = document

`pointermove` event not working with touch. Why not?

前提是你 提交于 2019-12-20 19:05:24
问题 I have this pen: https://codepen.io/anon/pen/eyKeqK If you try it on a touch-screen device (f.e. visit the pen on your phone) you'll notice that when you drag, the white light (the little sphere) only moves for a tiny bit then it stops working. The logic for the movement is in the pointermove event handler. It works fine on Desktop using a mouse, just not with touch. How do we fix this so the light keeps moving while touch dragging (not just for a moment), and as bonus how do we prevent it

Detect if an element is visible (without using jQuery)

╄→гoц情女王★ 提交于 2019-12-20 17:49:09
问题 I'm trying to detect if an html element I gave an id is visible or not without using jquery. The context: In the forgotten user password page, I have a form where the user enter his login name and clicks on submit. After that, if he has set a challenge question, it will be shown and he will be able to answer this question and submits again. (same button before). My problem: when the user clicks on submit, in IE, if he clicks on it several times, he'll get one e-mail for each time he clicks on

When should I observe Javascript events on window vs. document vs. document.body?

岁酱吖の 提交于 2019-12-20 16:50:13
问题 I'm using prototype.js for my web app, and I have everything running on Chrome, Safari, and Firefox. I am now working on IE8 compatibility. As I've been debugging in IE, I've noticed that there are Javascript events for which I have previously set an observer on the window, e.g. Event.observe(window, eventType, function () {...}); (where eventType might be "dom:loaded" , "keypress" , etc.) and it works just fine in Chrome/Safari/Firefox. However, in IE the observer never fires. In at least