I have a document with a dynamic UI--users can add rows to an existing data entry form as needed to provide more information.
I'm using a simple array to track what items are on the screen so I can prompt for save, but I'm having trouble figuring out how to add the ID of the new item to my array. The logic that works for existing items is
$(document).ready(function () {
$('.monitor').each(function () {
monitorIds.push($(this).attr('id'));
monitorValues.push($(this).val());
});
});
I was hoping to be able to do something along these lines, but can't find a suitable way to do it: (I'm aware that this doesn't work, as the 'live' method isn't defined with an event)
$('.monitor').live(function () {
monitorIds.push($(this).attr('id'));
monitorValues.push($(this).val());
});
I've seen the LiveQuery plug in, but as I'm already deep into plugin hell, was hoping to avoid adding yet another one. Is there a better way?
EDIT: I wasn't clear about one point--I'm trying to keep this in a separate script, and do it dynamically, rather than update each script that might add elements to also call a function to add the element(s) to the monitoring array. Just trying to keep the work of the team to a minimum to implement this, even after they've written scripts to do the UI work.