PDA

View Full Version : event.preventdefault



dolittle
6 Apr 2007, 6:48 AM
Hi

I was looking at the Event functions and saw the usage of preventdefault which as far as I know goes with FF but didn`t see the IE equivalent returnvalue.

I didn`t see a bug or something but I can`t understand how could the returnvalue be neglected. I would expect something like:

if (evt.returnValue) {
evt.returnValue = false;
} else if (evt.preventDefault) {
evt.preventDefault( );
} else {
return false;
}

Is it something to do with the fact that the Ext event is not the usual e event?
If it does don`t you have to use returnvalue at least once in the Ext lib?

Thanks

tryanDLS
6 Apr 2007, 7:22 AM
The event object is a normalized event object that wraps the browser event and provides a common interface. See this
http://extjs.com/deploy/ext/docs/output/Ext.EventObject.html

dolittle
6 Apr 2007, 8:42 AM
Hi

I do understand that the event is normalized but I couldn`t find where in the library it`s being normalized. Maybe this is complicated then I expected.

Thanks

tryanDLS
7 Apr 2007, 9:31 AM
What you're looking for happens, it's just buried pretty deep in the code. Eventually after going thru the Ext Event stuff you'll get to this in YUI's event object


/**
* Prevents the default behavior of the event
* @method preventDefault
* @param {Event} ev the event
* @static
*/
preventDefault: function(ev) {
if (ev.preventDefault) {
ev.preventDefault();
} else {
ev.returnValue = false;
}
},