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 7541409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:53:03+00:00 2026-05-30T07:53:03+00:00

here is a simple question. I have a ‘ul’ which i have made sortable

  • 0

here is a simple question. I have a ‘ul’ which i have made sortable via jquery-ui’s sortable() function. I want to remove elements when they are dragged off the list. The way i have it implemented works in the sense that when i drag an element away from the list it gets removed, but it also gets removed when i just rearrange the list. How do i achieve the behavior i am looking for without this unintended behavior. Below is all the code:

<html>
<head>
    <link type="text/css" href="jquery-ui/css/ui-lightness/jquery-ui-1.8.17.custom.css" rel="Stylesheet" /> 
    <script type="text/javascript" src="jquery-ui/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="jquery-ui/js/jquery-ui-1.8.17.custom.min.js"></script>

    <script type="text/javascript">
    $(function(){
        $('#sortme').sortable({
            out: function(event, ui){
                ui.item.remove();
            }
        });
        $('#sortme').disableSelection();
    });
    </script>

    <style>
    li{
        list-style-type: none;
        width: 200px;
        height: 50px;
        border: 1px solid #000;
        text-align: center;
        box-sizing: border-box;
        padding-top: 15px;
    }
    </style>
    <title> jqui sort test </title>

</head>
<body>
    <ul id='sortme'>
        <li>0</li>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
    </ul>
</body>
</html>

Thank you for your help!

  • 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-30T07:53:05+00:00Added an answer on May 30, 2026 at 7:53 am

    You could try to use a variable to check if the items you are dragging is dragged out of its parent container.

    You can use the over and out events of the jQuery UI sortable to assign the value for this variable and then execute the removal of the dragged item on the beforeStop event.

    here is a demo of what I have come up with: http://jsfiddle.net/drewP/m7VJq/1/

    let me know if it works for you.

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

Sidebar

Related Questions

Simple question here. I have a C# program which needs to stores some files
Here's a simple question. I have a jqGrid that's working great but I want
I have what is probably a simple question here about Castle Windsor, which I
all.I'm a beginner of Mysql and I have one simple question here. I want
Should be pretty simple question here. I have @Html.EditorFor(model=>model.Training) I dont want to show
I have a simple question here. I know with jQuery you can dynamically append
A simple question here for many of you. I have an indeterminate NSProgressIndicator which
I have a real simple question here. I only want to know if there
I'm trying to learn WPF, so here's a simple question, I hope: I have
Here's a very simple question. I have an SP that inserts a row into

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.