Administrator
2023-04-17 63fbfddabe08e353ad75e495c2ac8dc5203da88c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var FormSamples = function () {
 
 
    return {
        //main function to initiate the module
        init: function () {
 
            // use select2 dropdown instead of chosen as select2 works fine with bootstrap on responsive layouts.
            $('.select2_category').select2({
                placeholder: "Select an option",
                allowClear: true
            });
 
            $('.select2_sample1').select2({
                placeholder: "Select a State",
                allowClear: true
            });
 
            $(".select2_sample2").select2({
                placeholder: "Type to select an option",
                allowClear: true,
                minimumInputLength: 1,
                query: function (query) {
                    var data = {
                        results: []
                    }, i, j, s;
                    for (i = 1; i < 5; i++) {
                        s = "";
                        for (j = 0; j < i; j++) {
                            s = s + query.term;
                        }
                        data.results.push({
                            id: query.term + i,
                            text: s
                        });
                    }
                    query.callback(data);
                }
            });
 
            $(".select2_sample3").select2({
                tags: ["red", "green", "blue", "yellow", "pink"]
            });
 
        }
 
    };
 
}();