Single and Double click event delay


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $('.dataLink').live('click', function(e) {
  2. var sourceURL = $(this).attr('title');
  3. var that = this;
  4. setTimeout(function() {
  5. var double = parseInt($(that).data('double'), 10);
  6. if (double > 0) {
  7. $(that).data('double', double-1);
  8. return false;
  9. }
  10. else
  11. {
  12. alert("single click");
  13. $.ajax({
  14. url: sourceURL,
  15. timeout: 10,
  16. processData: false,
  17. success: function(data) {
  18. $('#contentBottom').html(data);
  19. },
  20. error: function(data) {
  21. //alert("timed out");
  22. }
  23. });
  24. }
  25. }, 300);
  26. }).live('dblclick', function(e) {
  27. $(this).data('double', 2);
  28. alert("double click");
  29. var modalUrl = $(this).attr('rel');
  30. $('.plotter').load(modalUrl).dialog('open');
  31. return false;
  32. e.stopPropagation();
  33. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.