Select2: marking event handler as 'passive'

Created on 18 May 2017  路  3Comments  路  Source: select2/select2

Hi,
I work with select 4.0.3 and i'm working with select2 ajax.
The problem is that ajax never fired up, i tried even changing placeholder never show up,
!!! any solution ?

$ajax= $(".ClientSearchSc");
/* recherche select2 + ajax */
$ajax.select2({
    ajax:{
        url: url+"/ajax/Cmd/Clients.php",
        dataType: 'json',
        delay: 0,
        data: function (params) {
            console.log(params.term);
            return {
                q: params.term, // search term
                page: params.page
            };
        }
        ,
        processResults: function (data,params) {
            // parse the results into the format expected by Select2
            // since we are using custom formatting functions we do not need to
            // alter the remote JSON data, except to indicate that infinite
            // scrolling can be used
            params.page = params.page || 1;

            return {
                results: data,
                pagination: {
                    more: (params.page * 30) < data.total_count
                }
            };
        },
        cache: true

    },
    minimumInputLength: 1
    ,
    escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
    templateResult: clientiFormatResult,
    templateSelection: clientiFormatSelection
});

even in chrome console i don't have error or in Network for XHR (client.php==> ajax file)
Sory for my english :smile:

troubleshooting

Most helpful comment

i find this probleme :
Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.

All 3 comments

hi, even when in use a simple select 2 with data, i copyed

var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];
$(".js-example-data-array").select2({
    data: data
})

it is the same not found result
i'm using select2 in same project for simple select and i don't have any probl猫me
cane some one help me please ???

i find this probleme :
Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.

@T-Nagui I don't believe this warning is related to your issue. See https://stackoverflow.com/a/39187679/2970321 and https://github.com/jquery/jquery/issues/2871 for information about Passive Event Listeners.

It's possible that your browser is caching some older, bad requests to your API endpoint. What happens if you set cache:false?

It sounds like you're having the same general issue as #5054. Does your API endpoint work properly when you access it directly in the browser (without Select2)?

Was this page helpful?
0 / 5 - 0 ratings