Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Wyciaganie data-attrubute z upuszczonego elementu na (droppable)
goartur
post
Post #1





Grupa: Zarejestrowani
Postów: 233
Pomógł: 27
Dołączył: 19.10.2014

Ostrzeżenie: (0%)
-----


Witam. Wiec chce aby po upuszczeniu elementu na element droppable zostal znaleziony data attribute upuszczonego elementu,

Kod:

  1. <html lang="en">
  2. <head>
  3. <meta charset="utf-8">
  4. <title>jQuery UI Droppable - Default functionality</title>
  5. <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  6. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  7. <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  8. <link rel="stylesheet" href="/resources/demos/style.css">
  9. #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
  10. #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }
  11. </style>
  12. $(function() {
  13. $( "#draggable" ).draggable();
  14. $( "#droppable" ).droppable({
  15. drop: function( event, ui ) {
  16. $( this )
  17. .addClass( "ui-state-highlight" )
  18. .find( "p" )
  19. .html( "Dropped!" );
  20. console.log($(ui.item).attr('data-parent'));
  21. }
  22. });
  23. });
  24. </script>
  25. </head>
  26. <body>
  27.  
  28. <div id="draggable" data-parent="sdsd" class="ui-widget-content">
  29. <p>Drag me to my target</p>
  30. </div>
  31.  
  32. <div id="droppable" class="ui-widget-header">
  33. <p>Drop here</p>
  34. </div>
  35.  
  36.  
  37. </body>
  38. </html>


Uzywac w tym momecie :
console.log($(ui.item).attr('data-parent'));

Lecz dostaje komunikat undefined
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 05:48