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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:48:57+00:00 2026-06-05T09:48:57+00:00

I have this code right here. I have two problems though: In the receive

  • 0

I have this code right here. I have two problems though:

  1. In the receive function, how can we get the element that just got dropped into the sortable? Not the one that was used to drop a new one, but the actual one that got dropped into the list?
  2. Since I couldn’t find that, I decided to use the drop() function, but now, why is that function getting called twice?! I don’t want that!

    $( "#sortable" ).droppable({
    
        activeClass: "ui-state-default",
        hoverClass: "ui-state-hover",
        drop: function( event, ui ) {
            $(ui.draggable).editable(function(value, settings) { 
                 return(value);
                 },{
                 tooltip     : "Click to edit"
              });
        }
    }).sortable({
    
        revert: true,
        receive: function(event, ui) {
            $(this).children("li").each(function(index) {
                $(this).attr("id", "content-" + index);
                });
        }
    
    });
    
  • 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-05T09:48:59+00:00Added an answer on June 5, 2026 at 9:48 am

    I was curious, so I did a bit of playing around with this.

    I did not see the ‘receive’ event fire at all in my testing with a droppable in play. Given that, I looked at your code, and it seems you want to set the id on the newly dropped. So, I did put together this: http://jsfiddle.net/ER5Jd/ – use that to see it in action adding the ID and listing the last list items id.
    Sort and it shows the new last one in the list after the sort. My hope is that it helps you.
    Note: ui.helper in the “drop” is the helper item that is dragging around the screen (draggable clone set) but the actual clone is from the draggable.

    my markup:

    <ul id='firstOne'>First
        <li class='listItem'>oneF</li>
        <li class='listItem'>twoF</li>
    </ul>
    <ul id='secondOne'>Second<span></span>
        <li class='listItem'>oneS</li>
        <li class='listItem'>twoS</li>
    </ul>
    

    my code:

    $('#firstOne .listItem').draggable({
        helper: 'clone'
    });
    giveId($('#secondOne'));// initial ids set
    
    $("#secondOne").droppable({
        activeClass: "ui-state-default",
        hoverClass: "ui-state-hover",
        drop: function(event, ui) {
            $(ui.draggable).clone().css('background-color', 'pink')
              .attr('id', 'content-' + ($(this).find('.listItem').length + 1))
              .appendTo(this).siblings().css('background-color', 'yellow');
            showId($(event.target));
        },
        accept: '#firstOne .listItem'
    }).sortable({
        revert: true,
        update: function(event, ui) {
            showId($(event.target));
        },
        receive: function(event, ui) {
            alert('receipt');
        }
    });
    
    function giveId(list) {
        list.find(".listItem").each(function(index) {
            $(this).attr("id", "content-" + index);
        });
        showId(list)
    }
    // show the last items id
    function showId(list) {
        list.find('span').text(list.find('.listItem:last').attr('id'));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
i have this code right here: <select name=group> <option value=>Choose a group....</option> <?php foreach($groups
I have a problem with this code right here: - (void)fetchedData:(NSData *)responseData { //parse
I have this code right now to get the row value from jquery grid..
So, I have this simple code $('#info_name'+index).show(slide, {direction: right}, 1000, function(){ $('#info_info'+index).show('slide',{direction: up}, 1000);
I have this code which compiles and works as expected: class Right {}; class
I have this code <a href=#> <span style=border-right: medium none; class=Yes>Yes</span> </a> <a href=#>
Right now, I have this code where $obj_arr maybe contain array and an object.
I have a lot of code in a big project that has two general
I am wondering how you would approach this problem I have two Taxrates that

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.