source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/demos/autocomplete/xml.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.1 KB
Line 
1<!doctype html>
2<html>
3<head>
4 <title>jQuery UI Autocomplete Remote 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 $.ajax({
20 url: "london.xml",
21 dataType: "xml",
22 success: function(xmlResponse) {
23 var data = $("geoname", xmlResponse).map(function() {
24 return {
25 value: $("name", this).text() + ", " + ($.trim($("countryName", this).text()) || "(unknown country)"),
26 id: $("geonameId", this).text()
27 };
28 }).get();
29 $("#birds").autocomplete({
30 source: data,
31 minLength: 0,
32 select: function(event, ui) {
33 log(ui.item ? ("Selected: " + ui.item.value + ", geonameId: " + ui.item.id) : "Nothing selected, input was " + this.value);
34 }
35 });
36 }
37 })
38
39 });
40 </script>
41</head>
42<body>
43
44<div class="demo">
45
46<div class="ui-widget">
47 <label for="birds">London matches: </label>
48 <input id="birds" />
49</div>
50
51<div class="ui-widget" style="margin-top:2em; font-family:Arial">
52 Result:
53 <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
54</div>
55
56</div><!-- End demo -->
57
58<div class="demo-description">
59<p>
60This demo shows how to retrieve some XML data, parse it using jQuery's methods, then provide it to the autocomplete as the datasource.
61</p>
62<p>
63This should also serve as a reference on how to parse a remote XML datasource - the parsing would just happen for each request within the source-callback.
64</p>
65</div><!-- End demo-description -->
66
67</body>
68</html>
Note: See TracBrowser for help on using the repository browser.