Select2 Search Detect if user is typing

时间:2016-10-20 20:10:41

标签: javascript select2

I'm working with select2 4.0.3 and I can't seem to detect keyup events. What is the right way to go about this?

My code:

Thanks!

$('.qty-select').select2({
        tags: true,
    }).change( function(e) {
        checkAmount(e);     
    }).on('select2:open', function (e) {
        checkAmount(e);
    }).on('select2:closing', function(e) {
        checkAmount(e);
        //alert($(".select2-search__field").val());
    }).on('select2:select',function(e) {
        alert('sdfsf');
    });

    $('.select2-search__field').on('keyup', function(e) {
        console.log('User is typing');
    });

1 个答案:

答案 0 :(得分:0)

您忘记准备好文件......

$(document).ready(function() {
    // other code here

    $('.select2-search__field').on('keyup', function(e) {
        console.log('User is typing');
    });
});