• I want to use Drag and Drop in WordPress for my Plugin.
    In my HTML File i get these Code and its works:

    <div id="dragandrophandler">Drag & Drop Files Here</div>
    <script>
    var obj = $("#dragandrophandler");
    obj.on('dragenter', function (e) 
    {
        e.stopPropagation();
        e.preventDefault();
        $(this).css('border', '2px solid #0B85A1');
    });
    obj.on('dragover', function (e) 
    {
         e.stopPropagation();
         e.preventDefault();
    });
    obj.on('drop', function (e) 
    {
     
         $(this).css('border', '2px dotted #0B85A1');
         e.preventDefault();
         var files = e.originalEvent.dataTransfer.files;
     
         //We need to send dropped files to Server
         handleFileUpload(files,obj);
    });
    
    $(document).on('dragenter', function (e) 
    {
        e.stopPropagation();
        e.preventDefault();
    });
    $(document).on('dragover', function (e) 
    {
      e.stopPropagation();
      e.preventDefault();
      obj.css('border', '2px dotted #0B85A1');
    });
    $(document).on('drop', function (e) 
    {
        e.stopPropagation();
        e.preventDefault();
    });
    
    </script>

    But not in WordPress how i included tere correct?

    Its in a Menu:

    function Menue() {
        add_menu_page('AdTicket', 'Upload', 10, __FILE__, 'uploader', 'dashicons-tickets-alt');  
    }
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You probably don’t have jQuery loaded on your admin page. It’s best to move your script to an external file, the use wp_enqueue_script() to load your file. By specifying jquery as a dependency, WP will load the jQuery library in the proper sequence to work with your script.

Viewing 1 replies (of 1 total)

The topic ‘Own WordPress Drag and Drop’ is closed to new replies.