I have a select field that is dynamically populated with an ajax call that simply returns all the HTML select options. Here is the part of the PHP that just echo\'s the sel
For items that are dynamically inserted into the DOM, their events must be bound with
$('.selector').bind('change',function() { doWork() });
This is because when you run $(function(){});
and bind events using $.click
or $.change
, etc., you are binding events to elements already existing in the DOM. Any manipulation you do after that does not get affected by whatever happens in the $(function(){});
call. $.bind
tells your page to look for future elements in your selector as well as current ones.