Dragan
Dragan

Reputation: 3743

detect typing in select2

I have a Select2, multiple: true, with tags. I would like to intercept the event of the user typing into the Select2 element. Not too sure if that's possible at all.

Any help would be greatly appreciated.

Thanks so much!

Upvotes: 3

Views: 3425

Answers (3)

user1966295
user1966295

Reputation: 1

$(document).on('input', '.select2-search__field',function () {
//do your stuff
});

Upvotes: 0

isherwood
isherwood

Reputation: 61083

var myOriginalInputId = 'myId';

$('#s2id_ ' + myOriginalInputId).on('keydown', function() {
    // do stuff
});

Upvotes: 2

Vranvs
Vranvs

Reputation: 1531

Are you referring to .keyup()?

$('#input').keyup(function(){

// function here

});

It detects a keyup event in an input box and executes a SIAF, as documented here;

http://api.jquery.com/keyup/

Upvotes: 0

Related Questions