Skip to content

Instantly share code, notes, and snippets.

@ericf
Created March 4, 2010 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericf/321525 to your computer and use it in GitHub Desktop.
Save ericf/321525 to your computer and use it in GitHub Desktop.
YUI().use('event-synthetic', 'node', function(Y){
/*!
* Technique from Juriy Zaytsev via jQuery 1.4.2
* http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
*/
function eventSupported (eventName) {
eventName = "on" + eventName;
var el = document.createElement("div"),
isSupported = (eventName in el);
if ( ! isSupported) {
el.setAttribute(eventName, "return;");
isSupported = typeof el[eventName] === "function";
}
el = null;
return isSupported;
};
var submitSupported = eventSupported('submit'),
changeSupported = eventSupported('change'),
resetSupported = eventSupported('reset');
//if ( ! submitSupported) {
Y.Event.define({
type : 'submit',
publishConfig : { emitFacade: false },
on : function (node, subscription, fireEvent) {
if (node.get('tagName') !== 'form'){
node.on('click', function(e){
//Y.once('submit'
});
}
},
detach : function (node, subscription, fireEvent) {}
});
//}
Y.one('form').on('submit', function(e){
Y.log('submit fired');
e.preventDefault();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment