accept.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Accept a Drop - 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>Accept a Drop</h2>
  14. <p>Some draggable object can not be accepted.</p>
  15. <div style="margin:20px 0;"></div>
  16. <div id="source" style="border:1px solid #ccc;width:300px;height:400px;float:left;margin:5px;">
  17. drag me!
  18. <div id="d1" class="drag">Drag 1</div>
  19. <div id="d2" class="drag">Drag 2</div>
  20. <div id="d3" class="drag">Drag 3</div>
  21. </div>
  22. <div id="target" style="border:1px solid #ccc;width:300px;height:400px;float:left;margin:5px;">
  23. drop here!
  24. </div>
  25. <div style="clear:both"></div>
  26. <style type="text/css">
  27. .drag{
  28. width:100px;
  29. height:50px;
  30. padding:10px;
  31. margin:5px;
  32. border:1px solid #ccc;
  33. background:#AACCFF;
  34. }
  35. .dp{
  36. opacity:0.5;
  37. filter:alpha(opacity=50);
  38. }
  39. .over{
  40. background:#FBEC88;
  41. }
  42. </style>
  43. <script>
  44. $(function(){
  45. $('.drag').draggable({
  46. proxy:'clone',
  47. revert:true,
  48. cursor:'auto',
  49. onStartDrag:function(){
  50. $(this).draggable('options').cursor='not-allowed';
  51. $(this).draggable('proxy').addClass('dp');
  52. },
  53. onStopDrag:function(){
  54. $(this).draggable('options').cursor='auto';
  55. }
  56. });
  57. $('#target').droppable({
  58. accept:'#d1,#d3',
  59. onDragEnter:function(e,source){
  60. $(source).draggable('options').cursor='auto';
  61. $(source).draggable('proxy').css('border','1px solid red');
  62. $(this).addClass('over');
  63. },
  64. onDragLeave:function(e,source){
  65. $(source).draggable('options').cursor='not-allowed';
  66. $(source).draggable('proxy').css('border','1px solid #ccc');
  67. $(this).removeClass('over');
  68. },
  69. onDrop:function(e,source){
  70. $(this).append(source)
  71. $(this).removeClass('over');
  72. }
  73. });
  74. });
  75. </script>
  76. </body>
  77. </html>