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.
Questions tagged [event-handling]
12746 questions
98
votes
4 answers
event.preventDefault() vs. return false (no jQuery)
I wondered if event.preventDefault() and return false were the same.
I have done some tests, and it seems that
If the event handler is added using old model, for example
elem.onclick = function(){
return false;
};
Then, return false prevents…

Oriol
- 274,082
- 63
- 437
- 513
95
votes
7 answers
Handle URL fragment identifier (anchor) change event in Javascript
How can I write the Javascript callback code that will be executed on any changes in the URL fragment identifier (anchor)?
For example from http://example.com#a to http://example.com#b

Bogdan Gusiev
- 8,027
- 16
- 61
- 81
93
votes
5 answers
How to removeEventListener that is addEventListener with anonymous function?
function doSomethingWith(param)
{
document.body.addEventListener(
'scroll',
function()
{
document.write(param);
},
false
); // An event that I want to remove later
}
setTimeout(
…

Japboy
- 2,699
- 5
- 27
- 28
90
votes
6 answers
How to trigger function on value change?
I realise this question has to do with event-handling and i've read about Python event-handler a dispatchers, so either it did not answer my question or i completely missed out the information.
I want method m() of object A to be triggered whenever…

neydroydrec
- 6,973
- 9
- 57
- 89
86
votes
5 answers
How do I make an Event in the Usercontrol and have it handled in the Main Form?
I have a custom usercontrol and I want to do something relatively simple.
When ever a numeric up down in that usercontrol's value changes, have the main form update a display window.
This is not a problem if the NUD was not in a usercontrol but I…

Crash893
- 11,428
- 21
- 88
- 123
84
votes
11 answers
How to distinguish between move and click in onTouchEvent()?
In my application, I need to handle both move and click events.
A click is a sequence of one ACTION_DOWN action, several ACTION_MOVE actions and one ACTION_UP action. In theory, if you get an ACTION_DOWN event and then an ACTION_UP event - it means…

some.birdie
- 2,259
- 4
- 24
- 28
84
votes
16 answers
Difference between event handlers and callbacks
What is the difference between an event handler and a callback function?

Aaron S
- 5,023
- 4
- 29
- 30
82
votes
3 answers
jQuery change method on input type="file"
I'm trying to embrace jQuery 100% with it's simple and elegant API but I've run into an inconsistency between the API and straight-up HTML that I can't quite figure out.
I have an AJAX file uploader script (which functions correctly) that I want to…

gurun8
- 3,526
- 12
- 36
- 53
81
votes
5 answers
.NET Events - What are object sender & EventArgs e?
What do sender and eventArgs mean/refer to? How can I make use of them (for the scenario below)?
Scenario:
I'm trying to build a custom control with a delete function, and I want to be able to delete the control that was clicked on a page that…

stringo0
- 2,720
- 7
- 38
- 52
80
votes
4 answers
What is an "event emitter"?
Browsing through http://microjs.com, I see lots of libraries labelled "event emitters". I like to think I know my way around the basics of the Javascript language pretty well, but I really have no idea what an "event emitter" is or does.
Anyone…

wwaawaw
- 6,867
- 9
- 32
- 42
79
votes
4 answers
C#: Difference between ' += anEvent' and ' += new EventHandler(anEvent)'
Take the below code:
private void anEvent(object sender, EventArgs e) {
//some code
}
What is the difference between the following ?
[object].[event] += anEvent;
//and
[object].[event] += new EventHandler(anEvent);
[UPDATE]
Apparently,…

Andreas Grech
- 105,982
- 98
- 297
- 360
78
votes
6 answers
How to overwrite jquery event handlers
I'll try to explain the problem with a simple code.
var fireClick = function() { alert('Wuala!!!') };
$('#clickme').click(fireclick);
$('#clickme').click(fireclick);
So now it will obviously alert 2 times but i need it alert only once. Tried so…

taras
- 2,223
- 5
- 36
- 43
75
votes
5 answers
Difference between the KeyDown Event, KeyPress Event and KeyUp Event in Visual Studio
Can anyone tell me the difference between the KeyDown event, the KeyPress event and the KeyUp event? I checked the msdn site and it does not explain it much.
Can anyone tell me in simple logical sense when each of the event occurs? I feel that all…

reggie
- 13,313
- 13
- 41
- 57
73
votes
3 answers
Is it bad practice to write inline event handlers
Is it bad practice to write inline event handlers ?
For me, I prefer use it when I want to use a local variable in the event handler like the following:
I prefer this:
// This is just a sample
private void Foo()
{
Timer timer = new Timer() {…

Homam
- 23,263
- 32
- 111
- 187
71
votes
9 answers
Do you need to remove an event handler in the destructor?
I use some UserControls which get created and destroyed within my application during runtime (by creating and closing subwindows with these controls inside).
It's a WPF UserControl and inherits from System.Windows.Controls.UserControl. There is no…

Martin Hennings
- 16,418
- 9
- 48
- 68