Skip to main content

Drag & Drop on Safari iOS: Wont drag, wont respond to drop on desktop/iPad


I am coding a webpage to be viewed on iPad. It uses Safaris/Webkits drag & drop. I have exactly copied Safari's example drag & drop code but it wont work.



My Problem: The ondrop event is never triggered when I run the webpage(HTML, CSS & Javascript) on Safari Desktop or on Safari on an iPad. On ipad I cannot even drag the elements(the microscope thingie appears & it wont drag when I hold & move my finger over the element). The drag does work on desktop though.



Whats going wrong?



The small code example can be found at the very bottom of this page: http://developer.apple.com/library/safari/#documentation/appleapplications/Conceptual/SafariJSProgTopics/Tasks/DragAndDrop.html



Here is the JSFiddle (remember the drag & drop is Webkit so only for Safari-this webpage is for ipad only): http://jsfiddle.net/eyM3y/


Source: Tips4allCCNA FINAL EXAM

Comments

  1. Working alternative :

    Firstly, use jquery UI http://jqueryui.com/demos/ for drag and drop functionality

    and then add this script https://github.com/furf/jquery-ui-touch-punch for playing it in Ipad or Iphone.

    Hope it helps.

    ReplyDelete
  2. I had a similar issue with one of my project but it can be resolved by following tutorial: http://popdevelop.com/2010/08/touching-the-web/ . It works for me I hope you will like it.

    ReplyDelete
  3. Did you read the top of the page you linked to in Apple's documentation? It says:


    Note: This technology is supported only on desktop versions of Safari. For iOS, use DOM Touch, described in Handling Events (part of Safari Web Content Guide) and Safari DOM Additions Reference.


    DOM Touch link

    Safari DOM Additions link

    I believe you may want to listen for the touchmove and touchend events instead of on drag and on drop. :)

    ReplyDelete

Post a Comment

Popular posts from this blog

Wildcards in a hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost . The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local , site2.local etc, and have them all resolve to localhost , while Apache serves a different site accordingly.