1 |
torben |
2125 |
<!doctype html> |
2 |
|
|
<html lang="en"> |
3 |
|
|
<head> |
4 |
|
|
<meta charset="utf-8"> |
5 |
|
|
<title>jQuery UI Selectable - Serialize</title> |
6 |
|
|
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> |
7 |
|
|
<script src="../../jquery-1.9.1.js"></script> |
8 |
|
|
<script src="../../ui/jquery.ui.core.js"></script> |
9 |
|
|
<script src="../../ui/jquery.ui.widget.js"></script> |
10 |
|
|
<script src="../../ui/jquery.ui.mouse.js"></script> |
11 |
|
|
<script src="../../ui/jquery.ui.selectable.js"></script> |
12 |
|
|
<link rel="stylesheet" href="../demos.css"> |
13 |
|
|
|
14 |
|
|
<style> |
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> |
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 |
|
|
|
37 |
|
|
<p id="feedback"> |
38 |
|
|
<span>You've selected:</span> <span id="select-result">none</span>. |
39 |
|
|
</p> |
40 |
|
|
|
41 |
|
|
<ol id="selectable"> |
42 |
|
|
<li class="ui-widget-content">Item 1</li> |
43 |
|
|
<li class="ui-widget-content">Item 2</li> |
44 |
|
|
<li class="ui-widget-content">Item 3</li> |
45 |
|
|
<li class="ui-widget-content">Item 4</li> |
46 |
|
|
<li class="ui-widget-content">Item 5</li> |
47 |
|
|
<li class="ui-widget-content">Item 6</li> |
48 |
|
|
</ol> |
49 |
|
|
|
50 |
|
|
<div class="demo-description"> |
51 |
|
|
<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> |
52 |
|
|
</div> |
53 |
|
|
</body> |
54 |
|
|
</html> |