Is there a way to prevent specific objects from being dropped?

Imagine having object1, object2, and object3. They are designated for dropping only in Zone1

Now, consider object4, object5, and object6. They can only be dropped in Zone2

How do I set up this configuration?

Additionally, I want object7 to be droppable in either Zone1 or Zone2, but not in Zone3

Currently, my configuration looks like this:

$(document).ready(function () {
        $(".draggable").each(function (index, item)
        {
            $(item).kendoDraggable({
                filter: ".handle",
                hint: function () {
                    return $('#box').clone().css("display", "block");
                },
                dragstart: draggableOnDragStart,
                dragend: draggableOnDragEnd
            });
        });

        $("#droptarget").kendoDropTarget({
            drop: droptargetOnDrop
        });

        $("#droptargetGauges").kendoDropTargetArea({
            filter: ".test1, .test2",
            drop: droptargetOnDrop
        });
    });

However, this setup allows any div with the class draggable to be dropped in either droptarget or droptargetGauges

Answer №1

To implement drag and drop functionality, you can utilize the group configuration option for both DropTarget and DropTargetArea:

Here is the HTML structure:

<div id='dragoptions'>
    <div class="draggable dragoption" id="person-one">person one</div>
    <div class="draggable dragoption" id="person-two">person two</div>
    <div class="draggable dragoption2" id="person-three">person three</div>
    <div class="draggable dragoption2" id="person-four">person four</div>
    <div class="draggable dragoption3" id="person-five">person five</div>
</div>
<div id="targets">
    <div class="droptarget type1" id="target1">role a</div>
    <div class="droptarget type1" id="target2">role b</div>
    <div class="droptarget type2" id="target3">role c</div>
</div>

And here is the corresponding JavaScript code:

 // JavaScript code goes here

For a live demonstration, you can click on this Demo link.

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

Starting a fresh SSH terminal directly from a web browser

I have an SSH IP address. Is it feasible to launch an SSH terminal through a web browser, similar to clicking on a hyperlink or Google Play store link? For instance: Click Here to Open SSH Terminal Upon clicking this link, the SSH session should open an ...

Assigning ng-view to "NAME" using RouteProvider

I'm completely new to Angular and I have a question regarding injecting a template or URL into multiple ng-views. However, my current approach involves having ng-view in my base template. My base template structure is as follows: <body> < ...

The CSRF token is required for this action to be completed

Just recently, I discovered how to set up a web server on a Raspberry Pi using Django. I'm in the process of enhancing it by integrating JS to generate a form every time data is sent. However, I've encountered an error that I haven't been ab ...

Breaking the link

My tabulator column contains text with line breaks that are displayed properly. However, when I use the built-in URL formatter, the line breaks disappear. {title:"Title", field:"title", formatter:"textarea"}, https://i.sstatic.net/N8XZP.png I attempted ...

Is it possible to refresh the browser with a specific URL using Node or Gulp?

Excuse me if this is not the appropriate place to pose my query. Unfortunately, due to the limitations of my workplace/CMS setup, I am unable to access a local version of the website for development purposes. Instead, we are working on CSS and JS locally ...

JavaScript function to double the odd numbers

I'm attempting to extract the odd numbers from the given array and then double them using the reduce method, but I keep getting an undefined error. Can someone please offer some guidance? const multiplyOddByTwo = (arr) => { return arr.reduce(( ...

Ways to prevent negative values from appearing in the text field

Check out this code snippet on Fiddle. I need help with a text field that should only display positive values. If the input is negative, I want it to be stored in ng-model but not shown in the textbox. function LoginController($scope) { $scope.number = ...

Tracking Clicks on Folders in jQuery File Tree

I am attempting to integrate a jQuery file tree into my website using the example provided below: Check out this jQuery file tree example While I can successfully trigger an event when a file is clicked, as demonstrated in the example, I am struggling to ...

Struggles with jquery and fixing images

I am currently working on a project where users can click on a thumbnail image to display a larger version in the main image section. $('.alternative_images a').click(function(e){ var imgSrc = $(this).attr('href'); $('.mai ...

Trouble arises when attempting to append a class through ng-class upon clicking

In a specific scenario, I am trying to change the border color from black to red in a div by appending a class using ng-class when clicked. However, when clicking a button, the modal opens but the class is not being appended as expected. <div ng-class ...

Encountering a loading error with r.js while attempting to optimize

In my main.js file, I have the following configuration for Require.js: /*--- Setting up Require.js as the main module loader ---*/ require.config({ baseUrl: '/javascripts/libs/home/', waitSeconds: 0, paths : { jquer ...

Reset the Bootstrap carousel following an Ajax request

Assembling the carousel from the bootstrap carousel after the Ajax call has been completed. Elements and classes are being appended post page load as shown below. async function ajaxCall() { let data = await fetch('ApiLink'); let jsonData ...

Tips on updating a JSON file exclusively using vanilla JavaScript with an AJAX call using the HTTP POST method?

Question One: I have been struggling to find a way to update a JSON file using the HTTP POST method when both files are stored on the same server (e.g. Godaddy or AWS). While I am able to send data to the server successfully, the JSON file is not being upd ...

Steps for signing up for an event using addEventSource in fullCalendar

Whenever I click on the dayClick event, my goal is to add an event to the date that was clicked. This is the JavaScript code I currently have: $('#calendar').fullCalendar({ header: { center: "title", // The title appears in the center ...

Show the value in the input text field if the variable is present, or else show the placeholder text

Is there a ternary operator in Angular 1.2.19 for templates that allows displaying a variable as an input value if it exists, otherwise display the placeholder? Something like this: <input type="text "{{ if phoneNumber ? "value='{{phoneNumber}}&a ...

React: The error message is saying that it cannot retrieve the 'handler' property because it is either undefined or null

I'm having some trouble with event handlers in my React.js project. Every time I try to create an event handler outside of the render function, I end up with an error. Can anyone help me figure out what I'm doing wrong? class CheckboxHandler ext ...

Generating landscapes with longitude and latitude coordinates in three.js

Is there a way to transform a cube geometry into a terrain based on latitude and longitude data? I have an array of objects with latitude, longitude, and deformation values for specific coordinates. var geo = new THREE.CubeGeometry( 10, 20, 40, 40, worldW ...

I've been waiting forever for Product.find() to return some results, but it seems to

I have been encountering an issue where my code is supposed to return an empty object of a product but instead it just keeps loading forever. I have thoroughly checked through the code and explored every possible scenario where an error could be occurring, ...

A beginner's guide to implementing Auth0 routing with the Next.js App Router

Is it possible to utilize Auth0 routes on the new App Router instead of the traditional Pages Router setup kit provided by Auth0? Learn more about App Router (Next.js) here: https://nextjs.org/docs/app Check out how to add the dynamic API route with Auth0 ...

Dependencies in Angular

After diving into Angular recently, I've been grasping the concepts well. However, one thing that still puzzles me is dependency injection. I'm unsure whether it's necessary to declare all components of my application (services, controllers ...