JavaScript Using Jquery to drag and drop, get value from dropped div drag using jquery

I am using Jquery to making drag and drop.

My short javascript to make an item to drag is:

$(".draggable").draggable();

My short javascript to make a dropable area is:

$("#droppable").droppable();

Here is my dragable item short HTML code:

 <div id="comItem[]" class="computerItem draggable">
    <img src="img/com.png" class="assetImg" alt="Computer Info" title="">
    <span id="owner[]" class="textLabel"></span>
    <span id="ipaddress[]" class="textLabel"></span>
 </div>

Does someone know how to get the values from dropped items in dropable area? I want to create the object array form the dropped items?

Thank you so much.

Answer:1

You can use the ui.draggable object in drop action

$( "#droppable" ).droppable({
    drop: function( event, ui ) {
        $(this).append($(ui.draggable).find('img'));
    }
})

Here ui.draggable is the element which you have dropped. (in this case the whole div)

Answer:2

I'm trying to wrap my head around Meteor's reactivity. I understand it re-renders a page when a reactive data source that's being referenced in a template changes. I also understand what constitutes a ...

I'm trying to wrap my head around Meteor's reactivity. I understand it re-renders a page when a reactive data source that's being referenced in a template changes. I also understand what constitutes a ...

  1. understanding meteor shower

I wrote this test code just to check if Angular is working with Jade. layout.jade doctype html html head title #{title} link(rel='stylesheet', href='/stylesheets/style.css') body(ng-app='...

I wrote this test code just to check if Angular is working with Jade. layout.jade doctype html html head title #{title} link(rel='stylesheet', href='/stylesheets/style.css') body(ng-app='...

  1. angular data binding types
  2. angular data binding example
  3. angular data binding not working
  4. angular data binding input
  5. angular data binding between components
  6. angular data binding not updating
  7. angular data binding radio buttons
  8. angular data binding cheat sheet
  9. angular data binding array
  10. angular data binding ngmodel
  11. angular data binding with function
  12. angular data binding observable
  13. angular data binding interview questions
  14. angular data binding object
  15. angular data binding input text
  16. angular data binding vs interpolation
  17. angular data binding from api
  18. angular data binding form
  19. angular data binding async
  20. angular data binding vs property binding

This is something I fear has been answered before, but I couldn't find anything. I am working on a modest web application. Part of it is a file-uploader which uploads xml-files to a Java servlet, ...

This is something I fear has been answered before, but I couldn't find anything. I am working on a modest web application. Part of it is a file-uploader which uploads xml-files to a Java servlet, ...

  1. combining like terms
  2. combining like terms worksheet
  3. combining pdf files
  4. combining form
  5. combining sentences
  6. combining cells in excel
  7. combining pdfs
  8. combining synonym
  9. combining like terms worksheet pdf
  10. combining vowel
  11. combining functions
  12. combining names
  13. combining sentences worksheet
  14. combining like terms activity
  15. combining like terms and distributive property worksheet
  16. combining word documents
  17. combining like terms puzzle
  18. combining like terms with negative coefficients
  19. combining exponents
  20. combining like terms video

I'd like to have the colour selected from a Primefaces ColourPicker sent to my backend on change. This seems not to be supported though. <p:colorPicker value="#{colorView.colorPopup}" /> I ...

I'd like to have the colour selected from a Primefaces ColourPicker sent to my backend on change. This seems not to be supported though. <p:colorPicker value="#{colorView.colorPopup}" /> I ...

  1. primefaces color picker ajax
  2. ajax color picker primefaces