SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Distinguishing between ondrag and onclick

    I am trying to implement a system where images can either be dragged to a certain location and then trigger an ajax call on doing so (which is working fine) or alternatively be clicked on without dragging and act as a normal link

    Unfortunately I cannot work out how to stop the link (or onclick) from firing after a drag has been performed. I need to somehow detect if the image has been dragged and prevent the onclick from firing if it has.

    I am currently using prototype/scriptaculous in Rails for the drag-and-drop but I am not averse to any solution

    Any help much appreciated!

  2. #2
    SitePoint Member
    Join Date
    Jul 2007
    Location
    Silion Valley
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rather than thinking of a way to stop the onclick from firing, why not set a flag (e.g. inDragMode) and set it to True when you get the ondrag. Then, in your onclick, simply exit if the flag is true.
    I've made every mistake and suffered every pain.
    So you don't have to.
    Stuck with JS or AJAX issue? Ask me here.

  3. #3
    SitePoint Evangelist bals28mjk's Avatar
    Join Date
    Aug 2007
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To prevent an event from firing and canceling it's effects use the stopPropogation method and cancelBubble property (for ie) found here.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •