Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chosen plugin change event not triggering

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?

like image 489
user3093453 Avatar asked Jan 22 '14 07:01

user3093453


2 Answers

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.

like image 113
Soundar Avatar answered Nov 20 '22 12:11

Soundar


Try this:

$(document).ready(function(){
    $("selector").chosen().change(function(){
        var id = $(this).val();
    });
})
like image 22
ace313 Avatar answered Nov 20 '22 12:11

ace313