Drag and drop feature in Ink Filepicker disabled following initial upload

By utilizing filepicker.makeDropPane() within a directive, any div with an ng-model can be transformed into a drop pane that saves the resulting InkBlob into the ngModel.

angular.module("app", []).directive("dropzone", function () {
  return {
    require: "ngModel",
    link: function (scope, element, attrs, ngModel) {

      filepicker.makeDropPane(angular.element(element)[0], {
        dragEnter: function () {
          console.log("Entered dropzone");
        },
        onSuccess: function (InkBlobs) {
          ngModel.$setViewValue({
            key: InkBlobs[0].key,
            url: InkBlobs[0].url
          }
        }
      });
    }
  }
});

The initial drag and drop upload will function properly. However, after a successful upload is made, subsequent drag and drop attempts will not trigger any action at all.

The dragEnter log message ceases to be displayed, which is unexpected. Normally, I would anticipate a disabled drop pane to behave like the rest of the browser window, where dragging a file onto it would simply open that file in the current tab. Nevertheless, when dragging a file onto the element following a previous successful upload, nothing happens – neither the dragEnter, dragLeave, onStart, onSuccess, nor

onError</code functions are executed; yet, the browser also does not open the file. The file only opens if dragged elsewhere outside the given element.</p>

<p>I suspected that angular might be interfering due to the directive templating, thereby disrupting the drop pane setup. Therefore, in an attempt to resolve this issue, I tried recompiling the directive in <code>onSuccess
using $compile(element)(scope). Unfortunately, this did not yield any impact.

What could be causing this behavior? It would make more sense if there was some form of feedback, but none of the callback functions provided are triggered once a successful upload has been completed.

Answer №1

The underlying cause of this issue still remains a mystery to me, but I managed to find a workaround that may be helpful for others facing a similar situation.

Instead of directly turning the element into a drop pane with

filepicker.makeDropPane(angular.element(element)[0], ...
, I decided to dynamically create a child div within the element and set up that child as the drop pane:

function create_pane () {
  var pane = angular.element("<div/>");
  element.append(pane);
  configure_pane(angular.element(pane)[0]);
}

function configure_pane (pane_node) {
  filepicker.makeDropPane(pane_node, {
    onSuccess:  save_img,
    ...
  });
}

After successfully saving an image, I remove the child node and then recreate and reconfigure the pane, effectively resetting the drop pane and allowing files to be dropped in again:

function save_img (InkBlobs) {
  ...
  reset_pane();
}

function reset_pane () {
  emptyNode(angular.element(element)[0]);
  create_pane();
}

This approach was inspired by Filepicker widget breaks after upload

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Include a series of HTML attributes within an HTML element

I need to take a string of attributes that are formatted in valid HTML and apply them to a specific HTML element, rather than just creating a new string with those attributes. For instance, I have a variable named attributesStr that contains the string of ...

How can you ensure data is saved during the process of moving datarows between two gridviews using drag and drop functionality?

I am currently working on implementing drag and drop functionality to move data between two gridviews. The goal is to save the data in a database on Azure once it has been moved from one gridview to another. However, I am facing an issue where the data is ...

Issues arise when using jQuery to manipulate HTML content within an Asp.Net environment

Recently, I found myself in a puzzling situation with a div that has the attribute runat="server". <div id="results" runat="server" class="results"></div> Using jQuery, I added HTML content to this div. $('.results').html('Add ...

The HTML5 range input is consistently defaulting to the minimum value and is not triggering the onChange event for text input

My goal is to implement a feature where an input type text is used along with an input type range with three specific use cases: 1. Default case: When the page loads, the slider should point to the value specified in the text input field. 2. When a user e ...

What is the best way to define the validity of an ng-model within a directive?

I am struggling with a directive to validate phone numbers in AngularJS. I want the ng-model to be considered invalid if the phone number is less than 10 digits. While trying out $setValidity, I encountered an issue where it says that it's not a funct ...

The initial load of Angular Google Maps within an accordion is displaying as a blank canvas

I've encountered an issue while using Angular Google Maps in conjunction with bootstrap3 and html5. Specifically, when I integrate angular google maps inside an accordion, the map appears blank the first time but functions normally when I return to th ...

Is there a way for me to retrieve a variable from within a .then function nested within another .then function?

Here is an example of code where I am attempting to log the value of 'a' to the console. driver.sleep(2000).then(function logAInConsole() { var a = ["Quas","Wex","Exort","Invoke"]; for(var i = 0; i < a.length; i++) { driver.sleep( ...

Formatting a ui-grid grid column in RC 3.0 to display currency

The options for the grid displayed below are meeting expectations in terms of data presentation. However, when attempting to format the value of row.entity[col.field] in my cellTemplate, I am not getting any data returned. Here is the code snippet: $scop ...

The app crashed unexpectedly when attempting to send a post request using the RestEasy Chrome extension

Looking to insert data into my mongodb collection with the name 'post'. Below is an excerpt from my server.js file: var express = require('express'); var app = express(); var bodyParser = require('body-parser'); var mongoos ...

How to retrieve the row index from a table using JavaScript

This question has cropped up numerous times, and despite trying various solutions suggested before, none of them seem to be effective in my case. Within a modal, I have a table where users can make changes that are then used to update the database. The ta ...

After manipulating the array, Vue fails to render the input fields generated by the v-for directive

After setting the value externally, Vue component won't re-render array items. The state changes but v-for element does not reflect these changes. I have a component that displays items from an array. There are buttons to adjust the array length - &a ...

Preserve the ajax controls while uploading files

I encountered a minor issue with file uploading. When I click the upload button, a window (ajax powered) pops up for selecting a file. However, as soon as the file is uploaded to the browser, the page reloads and the window closes, leaving me without the ...

Revealing concealed content within a Bootstrap modal

I am seeking a way to utilize bootstrap modal in order to display certain contents. Specifically, the email, gender, and status information should initially be hidden and revealed only upon clicking the "view more" button. My goal is to showcase this dat ...

Is it possible to invoke a method beyond a directive's scope?

I am new to using directives in Angular and I have encountered an issue that I need help with. I have a file called common.js which contains the following method: function showAlert(value) { alert(value); } Within my directive: app.directive('cc ...

Selecting a variety of shapes from a painting

Within my canvas, there are various shapes like ovals, triangles, and squares. I am curious to know if it is possible to obtain a reference to one of these objects and animate it whenever a specific event occurs. Appreciate your attention to this query. I ...

Submitting AJAX form to a PHP script instead of a traditional submission

I'm facing an issue with using AJAX to post a basic insert query to the database. The problem arises from generating multiple PHP forms in a while loop, all sharing the same class for HTML forms. I tried using the live function in AJAX but it hasn&apo ...

Steps to toggle text color upon clicking and switch the color of another text

As a beginner with no Js knowledge, I am trying to achieve a specific function. I want to be able to change the color of text when it is clicked, but also have the previously clicked text return to its original color. <div class="mt-5 fi ...

Leveraging Snowflake as a Data Type within Mongoose Schema

Context: Discord.js utilizes Snowflakes to distinguish between various items such as messages, members, and guilds. In my current situation, I am employing snowflakes as distinct identifiers for members within the guild, serving as the primary key in my Mo ...

Ways to Access Python List in JavaScript within a Django Template

I am currently working in oTree, a Django based environment for social experiments. I have encountered an issue while attempting to import lists from Python into an HTML template for use in Javascript. Although I can successfully display the lists in HTML ...

Ways to switch out error message for an error landing page

I am currently displaying error text when something goes wrong, but I would like to enhance the user experience by redirecting to a well-designed error page instead. Can anyone provide guidance on how to achieve this? Below is my existing code for display ...