basic.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Basic Droppable - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Basic Droppable</h2>
  14. <p>Drag the boxed on left to the target area on right.</p>
  15. <div style="margin:20px 0;"></div>
  16. <div style="float:left;width:200px;margin-right:20px;">
  17. <div class="title">Source</div>
  18. <div>
  19. <div class="dragitem">Apple</div>
  20. <div class="dragitem">Peach</div>
  21. <div class="dragitem">Orange</div>
  22. </div>
  23. </div>
  24. <div style="float:left;width:200px;">
  25. <div class="title">Target</div>
  26. <div class="easyui-droppable targetarea"
  27. data-options="
  28. accept: '.dragitem',
  29. onDragEnter:function(e,source){
  30. $(this).html('enter');
  31. },
  32. onDragLeave: function(e,source){
  33. $(this).html('leave');
  34. },
  35. onDrop: function(e,source){
  36. $(this).html($(source).html() + ' dropped');
  37. }
  38. ">
  39. </div>
  40. </div>
  41. <div style="clear:both"></div>
  42. <style type="text/css">
  43. .title{
  44. margin-bottom:10px;
  45. }
  46. .dragitem{
  47. border:1px solid #ccc;
  48. width:50px;
  49. height:50px;
  50. margin-bottom:10px;
  51. }
  52. .targetarea{
  53. border:1px solid red;
  54. height:150px;
  55. }
  56. .proxy{
  57. border:1px solid #ccc;
  58. width:80px;
  59. background:#fafafa;
  60. }
  61. </style>
  62. <script>
  63. $(function(){
  64. $('.dragitem').draggable({
  65. revert:true,
  66. deltaX:10,
  67. deltaY:10,
  68. proxy:function(source){
  69. var n = $('<div class="proxy"></div>');
  70. n.html($(source).html()).appendTo('body');
  71. return n;
  72. }
  73. });
  74. });
  75. </script>
  76. </body>
  77. </html>