dom-events

Saving the application state on cordovas pause with angular

家住魔仙堡 提交于 2020-01-25 20:14:27
问题 I've got a Cordova app running on my Android device to show some news retrieved from a web service. As I'm using Typescript and Angular I've got a service holding my news like so: class NewsService { news: News[]; } I'd like to save those news on Cordova's pause event, so I built a service to do that, injected it into my NewsService and added an event handler with a corresponding callback: static $inject = ["$http", "newsApp.LocalStorageService"]; constructor(private $http: ng.IHttpService,

Call JS function from HTML

六月ゝ 毕业季﹏ 提交于 2020-01-25 11:12:09
问题 I am unable to call a function from HTML file. This seems simple and my code matches what I've seen in similar SO answers, but I am missing something still. I know the JS is loading/running because the game in the canvas is working. Edit: Chrome console returns "testFunction is not defined" meaning the JS is NOT loaded. Why? This is a test in the JS file: function testFunction(){ alert("It works!"); } and it's called from the HTML like so: <button type="button" onclick="testFunction()" id=

How do I get the URL for a dropped image using a Chrome userscript?

我怕爱的太早我们不能终老 提交于 2020-01-24 02:19:08
问题 In the following chrome user script, how can I get a url for an image that I drag from my desktop? Where I have the debugger line, I'm getting the empty string for e.dataTransfer.getData("text") and e.dataTransfer.getData("url") // ==UserScript== // @match http://*/* // @match https://*/* // ==/UserScript== function preventDrag(e) { e.stopPropagation(); e.preventDefault(); } function handleDrop(e) { console.log("Just dropped: " + e.dataTransfer.files[0].name); debugger // TODO: grab the url

Want to add “addEventListener” on multiple elements with same class

感情迁移 提交于 2020-01-23 07:52:15
问题 I'd like to perform the logic in the "onClick" through the event listener in jS but it only seems to run once? I have the class in all four but I can't figure out why it seems to only work for the first? HTML: <button id='btn-1' type="button" name="first" class="breakdown main-text" onclick="enableButton('btn-2');disableButton('btn-1');show('btn-1')"> Breakdown Start </button> <button id='btn-2' type="button" name="second" class="breakdown main-text" onclick="enableButton('btn-3')

Actions through WebDriver will not trigger the blur event

情到浓时终转凉″ 提交于 2020-01-23 07:35:12
问题 I have a web page with two dropdowns. Selecting an option in one dropdown will update the list of options in the other dropdown through a script that's triggered by the blur event. The blur event is triggered when the focus moves away from the first dropdown. This all works fine when navigating the page manually. However, when performing the same steps through WebDriver, the blur event is never triggered, and the dropdown is thus never updated, causing my script to fail. Here's the html for

d3 - trigger mouseover event

試著忘記壹切 提交于 2020-01-23 04:46:28
问题 I have a map of the US states and counties in a SVG graphic rendered by D3. Each path have mouseover, mouseout and click events bound to it, as well as the FIPS county code set as the path ID. I have a jQuery Autocomplete input where the user can input the name of a state or county. Given that input, which makes the corresponding FIPS ID available, how can I trigger the mouseover event programatically? 回答1: I figured out the answer. The main problem is D3 does not have an explicit trigger

addEventListener, “change” and option selection

青春壹個敷衍的年華 提交于 2020-01-19 06:54:25
问题 I'm trying to have dynamic select list populate itself, from a single selection to start: <select id="activitySelector"> <option value="addNew">Add New Item</option> </select> and then JavaScript code we have: addEventListener("select", addActivityItem, false); The problem is that various events don't fire when you have one item: not "change" because, the text is no different when you select that item; not "select" (as I have here), for a roughly similar reason, because I'm not really

addEventListener, “change” and option selection

旧时模样 提交于 2020-01-19 06:54:18
问题 I'm trying to have dynamic select list populate itself, from a single selection to start: <select id="activitySelector"> <option value="addNew">Add New Item</option> </select> and then JavaScript code we have: addEventListener("select", addActivityItem, false); The problem is that various events don't fire when you have one item: not "change" because, the text is no different when you select that item; not "select" (as I have here), for a roughly similar reason, because I'm not really

addEventListener, “change” and option selection

非 Y 不嫁゛ 提交于 2020-01-19 06:54:07
问题 I'm trying to have dynamic select list populate itself, from a single selection to start: <select id="activitySelector"> <option value="addNew">Add New Item</option> </select> and then JavaScript code we have: addEventListener("select", addActivityItem, false); The problem is that various events don't fire when you have one item: not "change" because, the text is no different when you select that item; not "select" (as I have here), for a roughly similar reason, because I'm not really

HTML5 Canvas: Get Event when drawing is finished

扶醉桌前 提交于 2020-01-19 05:37:59
问题 I'm drawing an image to a canvas element. I then have code that depends on this process to be finished. My code looks like this: var myContext = myCanvasElement.getContext('2d'), myImg = new Image(); myImg.onload = function() { myContext.drawImage(containerImg, 0, 0, 300, 300); }; myImg.src = "someImage.png"; So now, I would like to be notified when drawImage is done. I checked the spec but I couldn't find either an event or the possibility to pass a callback function. So far I just set a