Tuesday, November 7th, 2006
DOM events in the Microsoft Ajax Library formerly known as Atlas
Evil Microsoft. The client-side DOM event model in Atlas (ASP.NET Ajax Extensions) was the IE model. Atlas implemented this model for the other browsers to make it work, and many didn't like this.
This has now all changed and a new API is in town.
The new model for DOM events is thus introducing a new API, but at least it's closely modeled after the standard APIs so it should feel pretty familiar. There are many differences in the implementations of DOM events that we needed to abstract. The first one is in the names of the methods that you call to add an event. In standard browsers, you use add/removeEventListener, in IE it's attach/detachEvent. The event names themselves are different: "click" is "onclick" in IE. Then, you have to abstract the signature of the event handlers themselves: in IE the parameters come from the global window.event object, in other browsers they are passed as a parameter. Finally, the contents of the event parameter object are themselves widely divergent from one browser to the other: mouse buttons don't have the same values for example, and some very useful stuff like mouse positions is missing altogether from the standard.
To do work you now:
-
-
// register a handler (shortcut for Sys.UI.DomEvent.addHandler)
-
$addHandler(myDomElement, "click", someFunction);
-
-
// Enums in event handlers
-
function myClickHandler(e) {
-
if (e.button === Sys.UI.MouseButton.leftButton) {
-
//...
-
}
-
}
-
-
function myKeyUpHandler(e) {
-
if (e.keyCode === Sys.UI.Key.enter) {
-
//...
-
}
-
}
-
There are also some other new features such as helpers to make component developers lives easier.
For example, an accessible hover behavior might want to subscribe to mouseover, mouseout, focus and blur. To do that, you'd typically create delegates to your handlers and then wire up these delegates to the DOM events one by one. From your "dispose" method, you'd also have to remove those handlers one by one and get rid of the delegates. Seeing that this pattern was repeated over and over again in almost any control or behavior sample, we decided to add helpers to batch those operations. So here's how you would wire up all those events:
-
-
$addHandlers(this.get_element(), {
-
mouseover: this._onHover,
-
mouseout: this._onUnhover,
-
focus: this._onHover,
-
blur: this._onUnhover
-
}, this);
-












We are now the knights who say “Ajax”!
Seems not to be something new. Or even relevant from the technical point of view. Something comparable could already be found in many other frameworks and toolkits e.g. mochikit, qooxdoo, dojo, … However it’s interesting that they really switched to more standard like names. Well done.
Sebastian: you’re right, it’s nothing particularly new, as the original post points out: “So we decided to change our compat layer and come back to a more conventional approach”.
ATLAS ROCKS…..!!!! :)
[...] Richard MacManus has posted on The State Of Web Development – Ajax set to surpass Flash in ‘07. … Category: Ajax, Usability, Games, Google, Comet, GWT … More Information [...]
Hi
I just launched this web 2.0 app called Matrix. this is pure AJAX driven app and it can convert any website into an instant community and can connect together all the people who are on that web site at that instant. I invite you to please come and share your thoughts on your experience with Matrix.
Thanks
Creator
I’m now the knights who say “Ajaxâ€!
________________
Free Software | Top Share Site | موبایل ، کامپیوتر
Mainstream music is gucci handbagsso far over the line in the negative directiongenuine gucci wallets that you can’t balance musical tastes without extra-special effort. Just tryauthentic gucci handbags at discount prices and avoid hearing the infectious, but insipid, “Wasted” from or the embarrassment that is “Becky,” courtesy of Plies.You couldn’t even catch a break from the Terrible gucci Id bi-FoldTrio–Gucci, Plies and Soulja Boy flower girl dressesTell ‘Em–during BET’s most recent Hip Hop Awards.cheap aion gold
Welcome To Replica Handbags Store! All products sold by
highreplica1 come directly from replica Louis
Vuittonmanufacturers and are guaranteed to be made with high quality leather materials and inspected
very carefully by our quality controller before we ship out your order to you. We offer various Designer replica handbags,like Louis Vuitton handbags,replica Gucci
handbags, replica Chanel
Handbags,replica YSL
handbags,Hermes Birkin Handbags etc.
We are all aware of the recent economic instability.
Discount Timberland
boots Store-Timberland
boots,Timberland
shoes