javascript-events

Binding javascript keypress events

旧城冷巷雨未停 提交于 2020-01-03 14:14:15
问题 I have a need to monitor the state of the Shift key, whether it is up or down. Its purpose is to notify the user that while the shift key is held down, the drag and drop operation they are about to perform is going to COPY the node(s), and not move them. I have it working perfectly with the code below, however, if I hold the Shift key and perform the drag and drop, the hook no longer exists; the screen no longer responds to the key press and remains in the "pressed" state. I'm guessing there

Access global event object in Firefox

 ̄綄美尐妖づ 提交于 2020-01-03 13:31:22
问题 The goal: run some functions on .ajaxStart() but only if fired by a certain event. The code: $('#loading_indicator').ajaxStart(function() { if(event != null){ if(event.type == 'hashchange' || event.type == 'DOMContentLoaded'){ $(this).show(); $('#acontents').hide(); $(this).ajaxComplete(function() { $(this).hide(); $('#acontents').show(); bindClickOnTable(); initFilterInput(); }); } } }); The problem: This does not work in Firefox. In Internet Explorer and Chrome I can happily access the

Receiving transformed mouse event data from DOM objects with a CSS 3D transform

痞子三分冷 提交于 2020-01-03 10:18:11
问题 Is there currently any data in a javascript mouse event that would allow me to easily find or calculate a mouse position relative to the 3D space of a transformed element? To illustrate visually, At left is the div without a 3d matrix, at right is the div after 3d transformation. o is the origin of the mouse event + /| / | +-----+ + | | | | | | o| => | o| | | | | +-----+ + | \ | \| + In the script below, clicking the same pixels in the div will report an event.layerX which is in the 2d

Delay JavaScript's function execution

余生颓废 提交于 2020-01-03 08:07:47
问题 I have a JQuery's .each loop that calls a function with a parameter per iteration, is there a way to delay this function call? I have tried setTimeout as in the following but this does not work as the function gets executed immediately. $.each(myArray, function (j, dataitem) { setTimeout(function () { showDetails(dataitem) }, 300); }); function showDetails(dataitem) { ... } Array size is roughly 20, What I'm trying to do is to distribute function calls over a certain time frame instead of

JQuery Autocomplete help

让人想犯罪 __ 提交于 2020-01-03 06:59:06
问题 I have a customised JQuery autocomplete control that is declared something like this. $('#SystemCode_Autocomplete').autocomplete({ source: [{"label":"Access","value":0},{"label":"Documentum","value":0}], //move values minLength: 1, change: function(event, ui) {// some function}, select: function(event, ui) {// some function} }); The change and select events are custom. The problem is if I type something into the textbox then click the submit button (i.e. no tab out, or lost of focus), or if I

analytics.js event not working properly

為{幸葍}努か 提交于 2020-01-03 03:57:10
问题 I implemented analytics.js (new version) in my ASPX webapplication. I got pageview working just fine, but events is very often not being send. In my example, I tried pushing 3 different buttons, but only one of them fired the event. I added an alert-box to each event, to verify that it actually is fired, and these all show. This is my js, placed just before the </head> (function(i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push

Refire the jQuery ready event?

☆樱花仙子☆ 提交于 2020-01-03 03:06:13
问题 I am using the jQuery $(document).ready() event on page. All is fine, except that if I am loading data using Ajax calls, the $(document).ready() event does not fire. I guess that it behave in such way because the page was already loaded and I am just adding more data from the Ajax response to the DOM. How can i refire the ready event ? 回答1: If you need to execute some additionnal Javascript, you might use a function that you call upon Ajax callback onComplete event : function initJS(){ //your

Read and display the text file contents upon click of button using javascript

*爱你&永不变心* 提交于 2020-01-03 03:02:24
问题 On click of a button called "result", I want to read and display a text file (which is present in my local drive location say: C:\test.txt ) using java script function and display the test.txt file contents in a HTML text area. I am new to java script,can anyone suggest the code for java script function to read and display the contents of .txt file ? Thanks and regards Deb 回答1: An Ajax request to a local file will fail for security reasons. Imagine a website that accesses a file on your

How to identify browser tab closing using javascript or jquery?

爱⌒轻易说出口 提交于 2020-01-03 02:56:36
问题 How to identify browser tab closing using javascript or jquery? I have to give a confirmation message when user click on the browser close button. If user press yes button I have to load another page on the same tab. if press cancel. then close the tab. any body knows the scripts for this functionality. Please help me :( 回答1: Try something like this: $(window).unload(function() { var bye = confirm("Go away?"); if (bye) { // do stuff window.location = "http://somewhere_else"; } else { // do

Change event not firing on textbox when data is changed through other code

此生再无相见时 提交于 2020-01-02 22:12:33
问题 I need a change event to fire on an element without regard of how the element value was changed. My use case here is that I need to change elements on a form whenever a particular textbox changes value. The problem is that the element is populated by another button (a calendar button that lets the user choose a date which is then inserted in the 1st textbox). Using the sample below, I need to know when "date1" changes so I can update "date2". I won't know the ID of the button--its dynamically