Skip to content

Instantly share code, notes, and snippets.

@rodneyrehm
Last active September 18, 2020 02:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodneyrehm/6464641 to your computer and use it in GitHub Desktop.
Save rodneyrehm/6464641 to your computer and use it in GitHub Desktop.
Rachel Nabors: touch and click
// https://coderwall.com/p/yzlqpq
(function($){
function touch(event) {
event.preventDefault();
var runFunc = $(this).data('activateRunFunc');
runFunc && runFunc();
}
function click(event) {
event.preventDefault();
event.stopImmediatePropagation();
var runFunc = $(this).data('activateRunFunc');
runFunc && runFunc();
}
$.fn.activate = function(runFunc) {
return $(this).data('activateRunFunc', runFunc).on({
touchend: touch,
click: click
});
};
})(jQuery);
@rodneyrehm
Copy link
Author

$('your-selector').activate(function (event) {
  console.log('event was dispatched', event)
})

does that help?

@andrenellin
Copy link

andrenellin commented Sep 23, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment