corrade-http-templates – Blame information for rev 62

Subversion Repositories:
Rev:
Rev Author Line No. Line
62 office 1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>jQuery UI Autocomplete - XML data parsed once</title>
7 <link rel="stylesheet" href="../../themes/base/all.css">
8 <link rel="stylesheet" href="../demos.css">
9 <style>
10 .ui-autocomplete-loading {
11 background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
12 }
13 </style>
14 <script src="../../external/requirejs/require.js"></script>
15 <script src="../bootstrap.js">
16 function log( message ) {
17 $( "<div/>" ).text( message ).prependTo( "#log" );
18 $( "#log" ).attr( "scrollTop", 0 );
19 }
20  
21 $.ajax({
22 url: "london.xml",
23 dataType: "xml",
24 success: function( xmlResponse ) {
25 var data = $( "geoname", xmlResponse ).map(function() {
26 return {
27 value: $( "name", this ).text() + ", " +
28 ( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ),
29 id: $( "geonameId", this ).text()
30 };
31 }).get();
32 $( "#birds" ).autocomplete({
33 source: data,
34 minLength: 0,
35 select: function( event, ui ) {
36 log( ui.item ?
37 "Selected: " + ui.item.value + ", geonameId: " + ui.item.id :
38 "Nothing selected, input was " + this.value );
39 }
40 });
41 }
42 });
43 </script>
44 </head>
45 <body>
46  
47 <div class="ui-widget">
48 <label for="birds">London matches: </label>
49 <input id="birds" />
50 </div>
51  
52 <div class="ui-widget" style="margin-top:2em; font-family:Arial">
53 Result:
54 <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
55 </div>
56  
57 <div class="demo-description">
58 <p>This demo shows how to retrieve some XML data, parse it using jQuery's methods, then provide it to the autocomplete as the datasource.</p>
59 <p>This 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.</p>
60 </div>
61 </body>
62 </html>