Witam. Wiec chce aby po upuszczeniu elementu na element droppable zostal znaleziony data attribute upuszczonego elementu,
Kod:
<title>jQuery UI Droppable - Default functionality
</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> #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; }
$(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'));
}
});
});
<div id="draggable" data-parent="sdsd" class="ui-widget-content"> <p>Drag me to my target
</p>
<div id="droppable" class="ui-widget-header">
Uzywac w tym momecie :
console.log($(ui.item).attr('data-parent'));
Lecz dostaje komunikat undefined