selva
selva

Reputation: 27

keypress events in jquery chosen

Keypress event is not working in jquery chosen. Below is my code:

$(".chzn-select").chosen();
$(".chzn-select").keypress(function () {
    $.ajax({
        url: "populateAirportCodes?fragments="+element.target,
        type: "POST",
        data: JSON.stringify(org),
        contentType: "application/json",
        async: false,
        success: function(data) {
            <** populate the data in chosen **>
        }
    });
});

Upvotes: 1

Views: 3301

Answers (1)

Stefan Breunig
Stefan Breunig

Reputation: 706

You can work around this by binding to the container instead:

 $(".chzn-select").chosen().data('chosen').container.bind('keypress', …);

However, this is internal API and might change between released. For your convenience, here’s a jsfiddle with this implemented.

Upvotes: 1

Related Questions