~dongpo-deng/sahana-eden/test

« back to all changes in this revision

Viewing changes to views/_searchbox.html

  • Committer: Deng Dongpo
  • Date: 2010-08-01 09:29:44 UTC
  • Revision ID: dongpo@dhcp-21193.iis.sinica.edu.tw-20100801092944-8t9obt4xtl7otesb
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 <FORM id="searchform" method="get" enctype="multipart/form-data" action="{{=URL(r=request)}}">
 
2
  <B>{{=T('Search')}}</B>: <INPUT size=30 id="searchbox" class="ac_input" type="text" autocomplete="off"/><input type="submit" id="search" value="{{=T('Details')}}"/>
 
3
 </FORM>
 
4
<script type="text/javascript">//<![CDATA[
 
5
$(function() {
 
6
    $("#searchbox").autocomplete('{{=URL(r=request, args='search', vars={'format':'json', 'filter':'~', 'field':extra or main})}}', {
 
7
        matchContains: true,
 
8
        dataType: 'json',
 
9
        parse: function(data) {
 
10
            var rows = new Array();
 
11
            for(var i=0; i<data.length; i++){
 
12
                rows[i] = { data:data[i], value:data[i].id, result:data[i].id };
 
13
            }
 
14
            return rows;
 
15
        },
 
16
        formatItem: function(row, i, n) {
 
17
            {{if extra:}}
 
18
            return row.id + ': ' + row.{{=main}} + ' - ' + row.{{=extra}};
 
19
            {{else:}}
 
20
            return row.id + ': ' + row.{{=main}};
 
21
            {{pass}}
 
22
                }
 
23
    });
 
24
    $("input#search").click(function() {
 
25
        // Set the Action URL
 
26
        $("form#searchform").attr("action","{{=URL(r=request)}}/"+$("input#searchbox").val());
 
27
        event.default();
 
28
        return false;
 
29
    })
 
30
});
 
31
//]]></script>