|
1 <!DOCTYPE html> |
|
2 <html lang="en"> |
|
3 <head> |
|
4 <meta charset="UTF-8" /> |
|
5 <title>jQuery UI Selectable - Serialize</title> |
|
6 <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> |
|
7 <script type="text/javascript" src="../../jquery-1.4.2.js"></script> |
|
8 <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> |
|
9 <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> |
|
10 <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> |
|
11 <script type="text/javascript" src="../../ui/jquery.ui.selectable.js"></script> |
|
12 <link type="text/css" href="../demos.css" rel="stylesheet" /> |
|
13 |
|
14 <style type="text/css"> |
|
15 #feedback { font-size: 1.4em; } |
|
16 #selectable .ui-selecting { background: #FECA40; } |
|
17 #selectable .ui-selected { background: #F39814; color: white; } |
|
18 #selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; } |
|
19 #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; } |
|
20 </style> |
|
21 <script type="text/javascript"> |
|
22 $(function() { |
|
23 $("#selectable").selectable({ |
|
24 stop: function(){ |
|
25 var result = $("#select-result").empty(); |
|
26 $(".ui-selected", this).each(function(){ |
|
27 var index = $("#selectable li").index(this); |
|
28 result.append(" #" + (index + 1)); |
|
29 }); |
|
30 } |
|
31 }); |
|
32 }); |
|
33 </script> |
|
34 </head> |
|
35 <body> |
|
36 <div class="demo"> |
|
37 |
|
38 <p id="feedback"> |
|
39 You've selected: <span id="select-result">none</span>. |
|
40 </p> |
|
41 |
|
42 <ol id="selectable"> |
|
43 <li class="ui-widget-content">Item 1</li> |
|
44 <li class="ui-widget-content">Item 2</li> |
|
45 <li class="ui-widget-content">Item 3</li> |
|
46 <li class="ui-widget-content">Item 4</li> |
|
47 <li class="ui-widget-content">Item 5</li> |
|
48 <li class="ui-widget-content">Item 6</li> |
|
49 </ol> |
|
50 |
|
51 </div><!-- End demo --> |
|
52 |
|
53 <div class="demo-description"> |
|
54 |
|
55 <p>Write a function that fires on the <code>stop</code> event to collect the index values of selected items. Present values as feedback, or pass as a data string.</p> |
|
56 |
|
57 </div><!-- End demo-description --> |
|
58 </body> |
|
59 </html> |