Chosen plugin change event not triggering

user3093453 picture user3093453 · Jan 22, 2014 · Viewed 48.1k times · Source

I'm using Chosen jQuery plugin and noticed that the change event is working only when the page loads, NOT every time the input field is being change.

How can I make it work every time the user changes the value of the input field?

Here is my code:

 $("#day").chosen().change({
     console.log('working');
  });

Am I missing something?

Answer

Soundar picture Soundar · Jan 23, 2014

To fire the standard change event, use like:

  $('#day').on('change', function(e) {
    // triggers when whole value changed
    console.log("value changed");
  });

To fire the event on each key press,

  $('#day').on('keyup', function(e) {
    // triggers when each key pressed
    console.log("key pressed");
  });

To know about the default events of chosen, refer here.