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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:09:53+00:00 2026-06-16T19:09:53+00:00

Please take a look at this jsFiddle. What I am trying to achieve is

  • 0

Please take a look at this jsFiddle.

What I am trying to achieve is to allow user to drag one of the three items on top and drop them into the sorted list. I have added a custom helper which is a placeholder right now and will be used for showing a preview of what that item will look like.

For the sake of discussion lets say the three draggable elements are source items, and what ends up in the sortable list is target items. What I am having difficulty is passing the right content to the stop function in the sortable list and inserting that content into the list instead of default clone of the source item. I also want to pass along some additional information with the source item. For example I want to know in the stop function if the element came from one of draggable source items or it is just one of the target items that is being reordered.

If you check the console you can see some of the unsuccessful attempts that I have made. I tried setting values in event.data but I get TypeError: event.data is null in the start and stop functions of the sortable list. So I think I am missing something here.

To reiterate my question, there are two related issues I am facing:

  1. How do I pass some data from when source item is being dragged to when it is dropped inside the sortable list which seems to trigger start and stop function of the sortable list?
  2. How do I insert a custom div inside the list instead of the default clone of the source item?

Any help will be appreciated.

  • 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-16T19:09:53+00:00Added an answer on June 16, 2026 at 7:09 pm

    It is a tricky question.

    The main problem is that the sortable and draggable widgets working together use clones of elements and not the elements themselves.

    As the JQuery data method store data for an element, it is not easy to bring the information because of the clone creation behavior described above.

    A workaround could be to use a simple div to store and retrieve the data in the events callback. It is working because there is always only one element dragged.

    Here is the code and the fiddle : http://jsfiddle.net/ghMaP/4/

    <ul id="draggable">
        <li class="ui-state-default">Button</li>
        <li class="ui-state-default">Text Field</li>
        <li class="ui-state-default">Image</li>
    </ul>
    
    <ul id="sortable" class="ui-state-highlight">
    </ul>
    
    <!-- New div used to store and retrieve data of dragged element -->
    <div id="tmp"></div>
    

    ​

    $(document).ready(function() {
    
        //Shortcut on the temp div
        $tmp = $("#tmp").get(0);
    
        $("#sortable").sortable({
            start: function(event, ui) {
            },
            stop: function(event, ui) { 
                //Here, we retrieve data from the temp div
                console.log("isNew : ", jQuery.data($tmp, "isNew"));
                console.log("resultHTML : ", jQuery.data($tmp, "resultHTML"));
            }
        });
    
        $("#draggable li").draggable({
            connectToSortable: "#sortable",
            start: function(event, ui) {    
    
                //Store info in a tmp div         
                jQuery.data($tmp, "isNew", true);
                jQuery.data($tmp, "resultHTML", "<b>Here I will add some custom html to EVENT data</b>");
    
            },
            helper: function(event) {
                return "<div class='custom-helper'>Custom helper for " + $(this).context.innerHTML + "</div>";   
            },
            revert: "invalid"
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi please take a look at this fiddle http://jsfiddle.net/bloodygeese/pwjNQ/1/ I am trying to figure
Please take a look at this http://jsfiddle.net/tt13/CFbpt/ What I need is, When user clicks
Can you please take a look at this JSFIDDLE sample which I am trying
please take a look at this fiddle : http://jsfiddle.net/cX47v/1 I am simply trying to
could somebody please take a look at this http://jsfiddle.net/bloodygeese/EzkFR/1/ My aim is to on
can someone take a look at this please http://jsfiddle.net/bloodygeese/ecscY/56/ it looks like I have
Please take a look at this piece of code. I'm allocating one byte for
Please take a look at this fiddle: http://jsfiddle.net/dhcyA/ Try clicking on a block. What
Please take a look at this simple code: http://jsfiddle.net/kerp3/ The box has an inner
Please take a look at my fiddle: http://jsfiddle.net/wWHz4/ This is what I made so

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.