javascript - Unable to call `change` event for cloned `select` control -


i have dynamically added new row clone last row. row contains select picker control.

how can create change event newly added control.

i have tried adding below script , not work.

console.log($('#${field_uid}-resourcetypepicker-new_' + u).attr('value'));  //prints  value correctly. 

//below event not called.

 $('#${field_uid}-resourcetypepicker-new_' + u).change(function() {             console.write('calling fine');  }); 

below rendered html stuff, copied firebug:

 <select id="customfield_11200-resourcetypepicker-new_3">      <option value="aaa">aaa</option>      <option value="ddd">ddd</option>      <option value="ddd">ddd</option>  </select> 

what can cause on this. ids match in change , select both customfield_11200-resourcetypepicker-new_3 same.

thanks

use on delegated event

$(document).on('change','#${field_uid}-resourcetypepicker-new_' + u,function() {     console.write('calling fine');  }); 

use closest static parent instead of document... better performance


Comments