Skip to content

Instantly share code, notes, and snippets.

@Ricardonacif
Created October 14, 2014 19:24
Show Gist options
  • Save Ricardonacif/880ea9d9238c26e3b8dd to your computer and use it in GitHub Desktop.
Save Ricardonacif/880ea9d9238c26e3b8dd to your computer and use it in GitHub Desktop.
Simulate Tap
var element_locator = '#fastclick';
function loadYui(callback) {
// Adding the script tag to the head as suggested before
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "http://yui.yahooapis.com/3.18.0/build/yui/yui-min.js";
// Then bind the event to the callback function.
// There are several events for cross browser compatibility.
script.onreadystatechange = callback;
script.onload = callback;
// Fire the loading
head.appendChild(script);
}
var tap = function() {
YUI().use('node-event-simulate', function(Y) {
var node = Y.one(element_locator);
node.simulateGesture("tap");
});
};
if (typeof YUI == 'undefined') {
loadYui(tap);
} else {
tap();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment