Posted By

Sullan on 04/28/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vitor_np


Single and Double click event delay


 / Published in: jQuery
 

  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  

You need to login to post a comment.