Questions tagged [event-handling]
Event handling is a coding style about handling messages between a source and one or more subscribers. A point listener in the source provide a way which subscribed code can consume messages raised from the source.
11,923
questions
3157votes
14answers
904kviews
event.preventDefault() vs. return false
When I want to prevent other event handlers from executing after a certain event is fired, I can use one of two techniques. I'll use jQuery in the examples, but this applies to plain-JS as well:
1. ...
824votes
10answers
2.2mviews
window.onload vs document.onload
Which is more widely supported: window.onload or document.onload?
720votes
12answers
1.1mviews
jQuery checkbox checked state changed event
I want an event to fire client side when a checkbox is checked / unchecked:
$('.checkbox').click(function() {
if ($(this).is(':checked')) {
// Do stuff
}
});
Basically I want it to happen ...
664votes
20answers
1.7mviews
jQuery checkbox change and click event
$(document).ready(function() {
//set initial state.
$('#textbox1').val($(this).is(':checked'));
$('#checkbox1').change(function() {
$('#textbox1').val($(this).is(':checked'));
});
...
618votes
15answers
240kviews
How to debug JavaScript / jQuery event bindings with Firebug or similar tools?
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 ...
613votes
22answers
392kviews
UITextField text change event
How can I detect any text changes in a textField? The delegate method shouldChangeCharactersInRange works for something, but it did not fulfill my need exactly. Since until it returns YES, the ...
516votes
2answers
672kviews
How can I trigger an onchange event manually? [duplicate]
I'm setting a date-time textfield value via a calendar widget. Obviously, the calendar widget does something like this :
document.getElementById('datetimetext').value = date_value;
What I want is:
On ...
377votes
15answers
123kviews
Why are only final variables accessible in anonymous class?
a can only be final here. Why? How can I reassign a in onClick() method without keeping it as private member?
private void f(Button b, final int a){
b.addClickHandler(new ClickHandler() {
...
356votes
13answers
415kviews
Understanding events and event handlers in C#
I understand the purpose of events, especially within the context of creating user interfaces. I think this is the prototype for creating an event:
public void EventName(object sender, EventArgs e);
...
300votes
10answers
123kviews
Difference between e.target and e.currentTarget
I don't understand the difference, they both seem the same but I guess they are not.
Any examples of when to use one or the other would be appreciated.
298votes
8answers
308kviews
jQuery - Detect value change on hidden input field
I have a hidden text field whose value gets updated via an AJAX response.
<input type="hidden" value="" name="userid" id="useid" />
When this value changes, I would like to fire an AJAX ...
274votes
2answers
368kviews
How can I capture the right-click event in JavaScript? [duplicate]
I want to block the standard context menus, and handle the right-click event manually.
How is this done?
268votes
14answers
125kviews
Android: Difference between onInterceptTouchEvent and dispatchTouchEvent?
What is the difference between onInterceptTouchEvent and dispatchTouchEvent in Android?
According to the android developer guide, both methods can be used to intercept a touch event (MotionEvent), ...
263votes
11answers
225kviews
How to call function on child component on parent events
Context
In Vue 2.0 the documentation and others clearly indicate that communication from parent to child happens via props.
Question
How does a parent tell its child an event has happened via props?...
260votes
3answers
5kviews
JavaScript click handler not working as expected inside a for loop [duplicate]
I'm trying to learn JS and got an issue.
I tried many things and googled but all in vain. Following piece of code doesn't work as expected. I should get value of i on click but it always returns 6. I'...