Angular-ui-tree supports the functionality of dropping an item into a specific

Currently, I am utilizing connected trees with Angular UI Tree. In this setup, Tree1 has a single level of depth, while Tree2 has an unlimited depth. My requirement is to enable the ability to drag any item from Tree2 INTO the items in Tree1 and capture that event.

To clarify further: Essentially, Tree1 represents the top-level items of Tree2, facilitating smooth movement of items within the overall data structure.

I couldn't find a direct method for accomplishing this in the existing documentation, so I took the following approach: I disabled dropping on Tree1:

<div ui-tree="tree1Options" id="tree1-root" data-nodrop-enabled='true'>

And then, I added the following callbacks on Tree2:

<div ui-tree="tree2Options" id="tree2-root">

$scope.tree2Options = {
dropped : function(event) {
      console.log("dropped" + event);
    },

    dragStop : function(event) {
      console.log("dragStop" + event);
    },

    beforeDrop : function(event) {
      console.log("beforeDrop" + event);
    },
}

Despite dragging an item from Tree2 onto Tree1 without showing a placeholder (which is acceptable), I'm unable to ascertain the specific destination where the drop occurred. It appears that the destination is being treated as the source.

Any suggestions? Furthermore, if you have a more efficient method for achieving the DROP INTO functionality, please share.

Answer №1

It appears that each scope has a single set of callbacks, but one potential solution could be to include a identifier in the data being passed so the system can determine which model it is associated with and trigger a specific function based on a case switch within the callback.

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

Adding a badge to a div in Angular 6: What you need to know!

How can I add a badge to a specific div in Angular 6? I have dynamic div elements in my HTML. I want to increase the counter for a specific div only, rather than increasing it for all divs at once. For example, I have five divs with IDs div1, div2, div3, ...

Tips for styling a button upon being clicked

Is there a CSS technique to make a button change color when clicked with the mouse? I am aware of using ':hover' for changing color, but I need something specific to a left mouse click. I want the same functionality as a standard button but with ...

Steps to incorporate user-provided information into a JSON format

Is there a way to use JavaScript to develop a function that enables users to update their user profile page (HTML) pulled from a JSON file? The process involves users entering their data into a form prompting for their responses (JS file in a routes folder ...

What is the best way to utilize two values in Vue.js 2?

When I attempt to structure my component in the following way: <script> export default { template: '\ <select class="form-control" v-on:change="search">\ <option v-for="option in option ...

Unable to transfer array elements to a function within PhantomJS

I am facing a challenge in extracting the source code from multiple webpages simultaneously. The links are stored in an array from a source text file. While I am able to successfully loop through the array and display the links, I encounter an issue when p ...

Should manual ID binding be utilized in backbone.js to establish connections between children and parents?

Currently, I'm developing an application that functions similarly to the Facebook wall feature. The main components are Posts and Comments. While the functionality is in place, I am using code like this within my Post Template to render the CommentV ...

Customizing the color of text in the fillText() function on an HTML5 <canvas>

I need help changing the color of each line of text in my canvas messages. I've tried creating variables for them, but haven't had any success. Any assistance would be greatly appreciated. function initialize(){ var elem = document.getElemen ...

Comparing Embedded and Linked JS/CSS

In my experience, I understand the advantages of using linked CSS over embedded and inline styles for better maintainability and modularity. However, I have come across information suggesting that in certain mobile web development applications, it may be m ...

Sluggish Performance of Material UI Table

Hey there! I've been working with Material-UI for a large data table, but I've noticed it's quite slow. Before reaching out on Github, I wanted to see if other users have any tips or workarounds to help improve performance. Here is the code ...

Enhancing Images in Next JS

Is there a way to incorporate the NextJS Image element into raw HTML response from the server, such as the following example: HTML = "<div> <p> Some Random text</p> <img src="image1.jpg" /> <img src="image2. ...

Use the clientID property of the controlname element within JavaScript to access the element using the getElementById method with only

I have a customized compound control that I need to deactivate. This control includes a text field and a calendar component. I want to disable both the image and the text field. Here is how it is identified on the page. The control's name is "datepic ...

What causes the DOM to be updated upon each opening of the browser extension for Chrome?

Here is the default position: https://i.stack.imgur.com/tkWCA.png After checking it: https://i.stack.imgur.com/tdzbg.png When I click anywhere on the page to hide the dom extension output (without showing popup.html); However, when I reopen the extens ...

Clicking on a Vue input field will reset its content

I am dealing with an input field that is set up like this: <input type="text" name="avr" value="{{ arv | currency}}" v-model="arv | currency"> The corresponding data model is defined as follows: data: { avr: '', } To populate the ...

Are the navigation arrows for moving to the previous and next month not displaying in the vue-bootstrap-datetimepicker component?

I have been utilizing this date picker, and it is functioning correctly. However, it seems to lack some CSS styling. Despite numerous attempts to implement the missing CSS code, I have not been successful. Below is the relevant section of my current code: ...

Interrogate an SQL server database using a combination of AngularJS and ASP.NET

I have a background in ASP.NET and web/database applications, and I am currently exploring Angular. While browsing w3schools.com, I came across an excellent database example that caught my attention: http://www.w3schools.com/angular/angular_sql.asp In pa ...

Empower the ability to collaborate across various time zones

I am currently managing an asp.net + c# application that tracks the working hours of employees using System.DateTime.now for logging purposes. With users connecting to the application from different countries, a client has requested that their employees wo ...

Is there a way to sort search outcomes by a drop-down menu in Next.js?

I am currently working on implementing a filter for my data based on selections made in a drop-down menu. Here's the setup: I have MSSQL data being pulled into NextJS using Prisma (ORM). My goal is to create a dropdown filter that will refine the di ...

Submitting an ajax form with the use of the symbol '&'

I am currently working on a form submission using the .ajax() method. Within my script, I have the following code: data: dataString, The variable dataString is composed of: var list = $('.listsummary').val() The listsummary class is assoc ...

Dynamic SVG positioning

Looking for a way to make this svg shape relative to its containing div? Fiddle: http://jsfiddle.net/8421w8hc/20/ <div> <svg viewBox="0 0 1000 2112" style="" xmlns="http://www.w3.org/2000/svg" version="1.1"> <path id="ma" st ...

Using filter to convert a string into an array and then utilizing it in ng-repeat functionality

I have a string in the format of "1200:2,1300:3,1400:2" that I need to display like this: <p>1200</p><p>2</p> <p>1300</p><p>3</p> <p>1400</p><p>2</p> I attempted to use a filter, ...