source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/demos/autocomplete/remote-jsonp.html@ 24245

Last change on this file since 24245 was 24245, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1<!doctype html>
2<html>
3<head>
4 <title>jQuery UI Autocomplete Remote JSONP datasource 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.position.js"></script>
10 <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script>
11 <link type="text/css" href="../demos.css" rel="stylesheet" />
12 <script type="text/javascript">
13 $(function() {
14 function log(message) {
15 $("<div/>").text(message).prependTo("#log");
16 $("#log").attr("scrollTop", 0);
17 }
18
19 $("#city").autocomplete({
20 source: function(request, response) {
21 $.ajax({
22 url: "http://ws.geonames.org/searchJSON",
23 dataType: "jsonp",
24 data: {
25 featureClass: "P",
26 style: "full",
27 maxRows: 15,
28 name_startsWith: request.term
29 },
30 success: function(data) {
31 response($.map(data.geonames, function(item) {
32 return {
33 label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
34 value: item.name
35 }
36 }))
37 }
38 })
39 },
40 minLength: 2,
41 select: function(event, ui) {
42 log(ui.item ? ("Selected: " + ui.item.label) : "Nothing selected, input was " + this.value);
43 },
44 open: function() {
45 $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
46 },
47 close: function() {
48 $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
49 }
50 });
51 });
52 </script>
53 <style>
54 .ui-autocomplete-loading { background: url(indicator.gif) no-repeat right; }
55 #city { width: 25em; }
56 </style>
57</head>
58<body>
59
60<div class="demo">
61
62<div class="ui-widget">
63 <label for="city">Your city: </label>
64 <input id="city" />
65 Powered by <a href="http://geonames.org">geonames.org</a>
66</div>
67
68<div class="ui-widget" style="margin-top:2em; font-family:Arial">
69 Result:
70 <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
71</div>
72
73</div><!-- End demo -->
74
75<div class="demo-description">
76<p>
77The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are cities, displayed when at least two characters are entered into the field.
78</p>
79<p>
80In this case, the datasource is the <a href="http://geonames.org">geonames.org webservice</a>. While only the city name itself ends up in the input after selecting an element, more info is displayed in the suggestions to help find the right entry. That data is also available in callbacks, as illustrated by the Result area below the input.
81</p>
82</div><!-- End demo-description -->
83
84</body>
85</html>
Note: See TracBrowser for help on using the repository browser.