1 | <!doctype html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <title>jQuery UI Droppable - Accept Demo</title>
|
---|
5 | <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
|
---|
6 | <script type="text/javascript" src="../../jquery-1.4.1.js"></script>
|
---|
7 | <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
|
---|
8 | <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
|
---|
9 | <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script>
|
---|
10 | <script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script>
|
---|
11 | <script type="text/javascript" src="../../ui/jquery.ui.droppable.js"></script>
|
---|
12 | <link type="text/css" href="../demos.css" rel="stylesheet" />
|
---|
13 | <style type="text/css">
|
---|
14 | #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }
|
---|
15 | #draggable, #draggable-nonvalid { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
|
---|
16 | </style>
|
---|
17 | <script type="text/javascript">
|
---|
18 | $(function() {
|
---|
19 |
|
---|
20 | $("#draggable, #draggable-nonvalid").draggable();
|
---|
21 |
|
---|
22 | $("#droppable").droppable({
|
---|
23 | accept: '#draggable',
|
---|
24 | activeClass: 'ui-state-hover',
|
---|
25 | hoverClass: 'ui-state-active',
|
---|
26 | drop: function(event, ui) {
|
---|
27 | $(this).addClass('ui-state-highlight').find('p').html('Dropped!');
|
---|
28 | }
|
---|
29 | });
|
---|
30 |
|
---|
31 | });
|
---|
32 | </script>
|
---|
33 | </head>
|
---|
34 | <body>
|
---|
35 | <div class="demo">
|
---|
36 |
|
---|
37 | <div id="draggable-nonvalid" class="ui-widget-content">
|
---|
38 | <p>I'm draggable but can't be dropped</p>
|
---|
39 | </div>
|
---|
40 |
|
---|
41 | <div id="draggable" class="ui-widget-content">
|
---|
42 | <p>Drag me to my target</p>
|
---|
43 | </div>
|
---|
44 |
|
---|
45 | <div id="droppable" class="ui-widget-header">
|
---|
46 | <p>accept: '#draggable'</p>
|
---|
47 | </div>
|
---|
48 |
|
---|
49 | </div><!-- End demo -->
|
---|
50 |
|
---|
51 | <div class="demo-description">
|
---|
52 |
|
---|
53 | <p>Specify using the <code>accept</code> option which element (or group of elements) is accepted by the target droppable.</p>
|
---|
54 |
|
---|
55 | </div><!-- End demo-description -->
|
---|
56 | </body>
|
---|
57 | </html>
|
---|