javascript-events

How do I keep events elements added through a ajax call in jQuery "active"

I'm placing content on my page through an ajax (post) request like so: $("input#ViewMore").click(function() { var data = { before: oldestDate, threadId: 1 }; $.post("/Message/More", data,function(html) { $('tbody#posts').prepend(html); return false; }, "html"); return false; }); with th...

JQuery event suppression..

hi, I have an input box, and I have bound both blur and keypress events to the input. but the problem is when there is a keypress event blur event also fires. Is there any way to suppress blur event when keypress event occurs? thanks ...

Cross-browser way to determine whether a DOM event was cancelled

Is there a cross-browser way from a javascript event handler to determine whether the event has been cancelled by a previous handler? IE and other browsers like Chrome etc. have an event.returnValue property that can be tested, but FireFox doesn't appear to have any such property. Here's an example of the scenario I'm talking about. You...

How to stop onkeyup event being fired when an alert box is cleared with the enter key

Here's my problem... I have a text field which uses the javascript onkeyup event to do some "quiet" validation with a tick or cross if the value is valid. When the enter key is pressed, it does the same validation, but with an alert box advising of any problems. If the enter key is used to clear the alert box, this press of the enter ...

Javascript confirmation dialog - ASP.NET

I saw a couple of similar questions on the same topic, but none of them addressed my issue. I've got a asp.net website, and want to show a status message (asp:label that will disappear in 5 seconds) to the user after the database was updated. i want to assign the text to the label, and then hide it with javascript. i got the js part ...

javascript blur event -- is there any way to detect which element now has focus?

Hello, Does anyone have a technique that will allow me to determine which element has focus after a blur event? I have an input field which I'd like to reset on blur unless the blur was caused by the user clicking the "save" button. I'd love to just set a flag in the save button's onclick funtion, but that would fire too late (unless cl...

getting the value of a form field after keypress event

Hello, myInput.value is one keystroke behind when I examine it in a keyPress event handler. So if the users types "a", myInput.value gives me "". Then when the user types "b", myInput.value gives me "a", and so it. The value doesn't seem to get updated with the character input by the keystroke that triggered the event. What am I doing wr...

How to stop further JavaScript events from executing

I'm using an Infragistics grid on a form and am handling multiple client-side events on the cells (e.g. cell click, before cell edit, before cell update, etc). On the cell click event, I'm spawning a secondary window (successfully) as follows: var convChartWindow = window.open("conversioncharts/" + currentCell.getValue() + ".html", "...

jQuery mouseout firing when injecting child element

I'm trying to create a function which will add an overlay to a thumbnail image when you hover over it and remove the overlay when you leave it. Here is my HTML... <div class="thumb"><img src="i/testThumb.gif" /></div> And here is my jQuery... $('.thumb').live('mouseover', function(event){ if($(this).find('.overlay').length == 0){...

IE onPaste event using javascript not HTML

It seems that the only way to add an onPaste event to an input element is to use HTML: <textarea id="text_area" onpaste="on_paste" /> rather than being able to attach the event handler using javascript: document.getElementById('text_area').onPaste = function() { alert('I iz in ur textbox, pasting some text') }; The MSDN website say...

Does a form reset button fire a select elements onChange event?

I have a form with some select elements that have onChange events attached to them. I would like the event to fire even when someone clicks the form reset button. My question is: does resetting a form fire a select elements onChange event? Here is a simple example in jQuery <script type="text/javascript"> $('.myselect').change(fun...

window.onbeforeunload detect if POST or GET

In the window.onbeforeunload event is there a way to detect if the new request is a POST(on the same page) or a GET(going to a page)? It would also be great to see the new document.location. window.onbeforeunload = winClose; function winClose() { //Need a way to detect if it is a POST or GET if (needToConfirm) { r...

scriptaculous draggables: need to cancel onClick action when element is dragged.

Thanks for the three excellent answers which all identified my problem of using "onclick = ..." instead of "observe( "click",..." But the award for Accepted Answer has to go to Paolo Bergantino for the mechanism of adding a class name to mark the dragged element, which saved me some more work! In my HTML I have a table with an image ...

How to prevent iframe from resizing parent window?

I have a page with iframe. Content inside iframe does window.parent.resizeTo calls (or something similar that in result resizes whole browser window). It does so to accomodate for its contents. I want to prevent resizing of whole browser window and just change the size of iframe element instead. Is there a way to intercept these resize...

Are events lost in jQuery when you remove() an element and append() it elsewhere?

What happens in jQuery when you remove() an element and append() it elsewhere? It appears that the events are unhooked - as if you were just inserting fresh html (which I guess is what happening). But its also possible my code has a bug in it - so I just wanted to verify this behavior before I continue. If this is the case - are there...

Javascript - Trying to wrap my head around custom events

I'm trying to get my head around custom events. I understand how to register and trigger custom events. However, it seems like its not possible to register truly custom events. Everything has to trace back to a DOM event like click, onload, blur, etc. Or am I wrong? For example, suppose I have an array. I want to register an event that ...

JavaScript / jQuery problem on Internet Explorer 7

I have a simple HTML page that looks like this: ...<div id="main"> <a href="#">Click here!</a> </div>... I have a piece of jQuery JavaScript in the header that looks like this: <script type="text/javascript"> $(document).ready(function() { DoHello(); }); function DoHello() { $("div#main a")....

How to debug Javascript/jQuery event bindings with FireBug (or similar tool)

I need to debug a web application that uses jQuery to do some fairly complex and messy DOM manipulation. At one point, some of the events that were bound to particular elements, are not fired and simply stop working. If I had a capability to edit the application source, I would drill down and add a bunch of Firebug console.log() stateme...

Best way to signal my JS script is loaded

I have a JS script that will be hosted on my server and that others will embed in their html, i.e. ...<code for http://yoursite.com /> <script type="text/javascript" src="http://mysite.com/awesome.js" /> ...<code for http://yoursite.com /> My script surfaces an object with a bunch of properties accessible for use as a javascript Objec...

window.onload vs document.onload

Which is more widely supported, window.onload or document.onload? ...