code_junkie

Preventing click event with Scriptaculous drag and drop

Nov 12th, 2011
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. new Draggable('id', {
  2. onStart: function() {
  3. dPhoto = $('id');
  4. Event.stopObserving('id', 'click');
  5. },
  6. onEnd : function() {
  7. setTimeout("Event.observe('id', 'click', function() { location.href = 'url'; });", 500);
  8. },
  9. revert: true
  10. });
  11.  
  12. new Draggable('tag',
  13. {
  14. revert:function()
  15. {
  16. $('tag').onclick = function(){return false;};
  17. setTimeout('$('tag').onclick = function(){return true;}','500');
  18. return true;
  19. }
  20. }
  21. );
  22.  
  23. var click_func;
  24. function onDragStart(drgObj,mouseEvent){
  25. click_func = mouseEvent.target.onclick;
  26.  
  27. mouseEvent.target.onclick = function(e){
  28. mouseEvent.target.onclick = click_func;
  29. return false;
  30. }
  31. }
  32.  
  33. function onDragStart() {
  34. Event.stopObserving(this.OBJECT,'click');
  35. Event.observe(this.OBJECT,'click',this.onDragEnd.bindAsEventListener(this));
  36. }
  37.  
  38. function onDragEnd() {
  39. Event.stopObserving(this.OBJECT,'click');
  40. Event.observe(this.OBJECT,'click',this.PREVIOUSFUNCTION.bindAsEventListener(this));
  41. }
Add Comment
Please, Sign In to add comment