autocomplete.tpl 1.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<input type="hidden" id="{{$id}}" name="{{$name}}" {{if $describedby}}aria-describedby="{{$describedby}}"{{/if}} value="{{$value}}"/>

<script type="text/javascript">
addLoadEvent(function () {
    jQuery("#{{$id}}").select2({
        initSelection : function(element, callback) {
            callback({{$initvalue|safe}});
        },
        multiple: {{$multiple}},
        width: "{{$width}}",
        allowClear: {{$allowclear}},
        {{if $hint}}placeholder: "{{$hint}}",{{/if}}
        minimumInputLength: {{$mininputlength}},
        ajax: {
            url: "{{$ajaxurl}}",
            dataType: 'json',
            data: function(term, page) {
                return {
                    q: term,
                    page: page,
                    sesskey: "{{$sesskey}}"
                }
            },
            results: function(data, page) {
                return {
                    results: data.results,
                    more: data.more
                };
            }
        },
        {{$extraparams|safe}}
    });
});
jQuery("#{{$id}}").prop('disabled', {{$disabled}});
</script>