Created
March 4, 2010 08:03
-
-
Save ericf/321525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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