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

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex