I have been researching the .on() function within jquery to update the DOM of a dynamic form and trigger an event onchange of a newly created dropdown box.
I've linked a fiddle here:
http://jsfiddle.net/6y18mho8/10/
the jquery I believe is causing my problem is here:
$('#orderDetail').ready(function () {
$("[id^=PN_]").on('change',function(event) {
var PN = $(event.target).val();
var ID = event.target.id;
alert('Successfully triggered by onChange from "'+ID+'"');
});
});
The code will fire on the initial row but not on newly created. Again, from everything I've read I need to reload/redefine the DOM to include my new elements via the .on() method. Am I on the right track and if so what am I missing?
Any guidance on this would be much appreciated.