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

  • SEARCH
  • Home
  • 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 8929121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:36:15+00:00 2026-06-15T08:36:15+00:00

I want to append a button on moved items that when clicked will remove

  • 0

I want to append a button on moved items that when clicked will remove the item from the list and return it to its original position. This plugin has the functionality I’m looking for but I’ve been searching all day and it looks like this is missing from .sortable.

What I have as a structure is:

<ul class="sortable">
  <li class="parent old">
    <h3 class="heading">User 1</h3>
    <a class="remove">X</a>
    <ul class="sortable">
      <li class="ui-state-default old">
        <h3>My Image</h3>
      </li>
      <li class="ui-state-default old">
        <h3>My Image 2</h3>
      </li>
    </ul>
  </li>
</ul>

Here’s the js:

$('.sortable').sortable({
    connectWith: [".newList"],
    handle: "h3",
    cursor: "move",
    placeholder: "placeHolder",
    opacity: 0.5,
    items: ".old",
    clone: "helper",
    revert: true
});
$('.remove').click(function(){
    $(this).prevAll('.parent:first').remove();
});

Experimenting with different things I can successfully envoke the .sortable(“destroy”) but that will do no good if it won’t appear in the original list again. There is another possible (not ideal) solution that I’ve been looking at here in this fiddle. Basically my thoughts on this solution is adding a destroy to the button and it is always in the original list. The problem here is that I really do need to at least hide this from the original and show it if the corresponding item is destroyed from the new list. So ideally I would like to do this with .sortable if possible.

  • 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-06-15T08:36:16+00:00Added an answer on June 15, 2026 at 8:36 am

    Borrowing from the jQuery Sortable examples, it seems something very similar to what you want should be possible.

    The key is in the connectWith property on the Sortable. This property can be set one-way. This allows you to set your initial list with a specific sortation that can be maintained while allowing the items to be dragged into your secondary list as desired. Example: http://jsfiddle.net/rvAgL/

    html:

    <ul id="sortable1" class="connectedSortable">
        <li class="ui-state-default">Item 1</li>
        <li class="ui-state-default">Item 2</li>
        <li class="ui-state-default">Item 3</li>
        <li class="ui-state-default">Item 4</li>
        <li class="ui-state-default">Item 5</li>
    </ul>
    
    <ul id="sortable2" class="connectedSortable">
        <li class="ui-state-highlight">Item 1</li>
        <li class="ui-state-highlight">Item 2</li>
        <li class="ui-state-highlight">Item 3</li>
        <li class="ui-state-highlight">Item 4</li>
        <li class="ui-state-highlight">Item 5</li>
    </ul>​
    

    js:

    $(function() {
            $( '#sortable1').sortable({
                connectWith: ".connectedSortable"
            }).disableSelection();
            $('#sortable2').sortable({
                update:function(ev, ui){
                    var widget = $(this);
                    var removeButton = $("<span>X</span>").click(function(){
                        var parentLi = $(this).parent();
                        $(this).remove();
                        parentLi.appendTo($('#sortable1'))
                         $('#sortable1 li').sort(asc_sort).appendTo($('#sortable1'));
                    });
                    $(ui.item).append(removeButton);
                }
            }).disableSelection();
    
        function asc_sort(a, b){
            return ($(b).text().toUpperCase()) < ($(a).text().toUpperCase());    
        }
    
    });​
    

    a bit of css:

     #sortable1, #sortable2 { list-style-type: none; margin: 0; padding: 0 0 2.5em; float: left; margin-right: 10px; cursor:pointer }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following list item that I want to append an 'Edit Settings'
I have an unordered list with elements and I want to append an item
I have a in-line delete button, I want to append more data to the
I want to append .item element before .content element but it just simply removes
As the title implies I'm trying to select items from one list box, press
When the browser clicks back button, I want to append &page=3 to the URL.
I want to append the panel that is created for the buttons in the
With the append button i add elements to the same class. I want the
I want to append some elements with a button. But they have to have
I want to repeatedly append the same stuff to an element via a button

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.