Kod:
<html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <style> #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; } #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; } </style> <script> $(function() { $( "#draggable" ).draggable(); $( "#droppable" ).droppable({ drop: function( event, ui ) { $( this ) .addClass( "ui-state-highlight" ) .find( "p" ) .html( "Dropped!" ); console.log($(ui.item).attr('data-parent')); } }); }); </script> </head> <body> <div id="draggable" data-parent="sdsd" class="ui-widget-content"> </div> <div id="droppable" class="ui-widget-header"> </div> </body> </html>
Uzywac w tym momecie :
console.log($(ui.item).attr('data-parent'));
Lecz dostaje komunikat undefined