Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7019985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:15:32+00:00 2026-05-27T23:15:32+00:00

I have a draggable element , that when its dropped onto the target, it

  • 0

I have a draggable element , that when its dropped onto the target, it adds a delete button:

    $( "#committed" ).droppable({
                hoverClass: 'drophover',
                drop: function( event, ui )
                {

                    $(function()
                    {
                        var done;

                        if( done ) return;
                        done = true;

                        $(ui.draggable).append('<button class="delBtn" type="reset">X</button>');

                        $(ui.draggable).draggable( "option", "disabled", true );

                        $( "#sortable" ).sortable();
                        $( "#sortable" ).disableSelection();                            

                    });

                }

Once its been dropped, it then becomes sortable. The issue is , everytime the element is sorted, the Delete button gets added again. As there are multiple elements being dragged and dropped and then sorted, so .length>? doesn’t work.

I essentially need

If (this.delBtn exists)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:15:32+00:00Added an answer on May 27, 2026 at 11:15 pm

    I updated another jsfiddle project, there the button is added only if the button does not exist on the draggable object yet: jsfiddle example

    The trick here is this:

    if ($(ui.draggable).find('button.delBtn').length == 0) {
          $(ui.draggable).append('<button class="delBtn" type="reset">X</button>');
    }
    

    It checks if the dragged item contains a button with class delBtn. If not then it adds the button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery: $(document).ready(function () { $(.element).draggable(); $(.element).droppable({ drop: function () {
I have dropped an element from a widget and drag it in the target.
I have a set of droppable li elements that accepts a draggable icon. The
I have multiple element that are jquery ui draggable, these elements can also be
so I have found that when I add both .draggable() and .droppable() to an
Having a slight spot of bother... I have a draggable element that can be
Is it possible to have a draggable element with more than one handle? I
I have a draggable div element with a hover style. This works fine, but
So i have one div element that i append on my DOM with a
I have some very long draggable elements that I can drop in all cells

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.