Reputation: 3359
I have dynamically added new row by clone the last row, this row contains select
picker control.
How can I create the change
event for newly added control.
I have tried by adding below script, but it does not work:
console.log($('#${field_uid}-resourcetypepicker-new_' + u).attr('value')); //prints value correctly.
//below event is not called.
$('#${field_uid}-resourcetypepicker-new_' + u).change(function() {
console.write('calling fine');
});
Below is the rendered HTML stuff, copied from Firebug:
<select id="customfield_11200-resourcetypepicker-new_3">
<option value="aaa">aaa</option>
<option value="ddd">ddd</option>
<option value="ddd">ddd</option>
</select>
Qhat can be the cause on this? Its IDs are also match in change
and select
both are customfield_11200-resourcetypepicker-new_3
same.
Upvotes: 0
Views: 182
Reputation: 36531
use on delegated event
$(document).on('change','#${field_uid}-resourcetypepicker-new_' + u,function() {
console.write('calling fine');
});
use closest static parent instead of document... for better performance
Upvotes: 2