accept.html 2.2 KB

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