I am trying to make this work for my page, but I need to understand the regular expression replacement. Can someone break this down for me?
function add_fields(link, association, content) {
var new_id = new Date().getTime();
var regexp = new RegExp("new_" + association, "g")
$(link).parent().before(content.replace(regexp, new_id));
}
I understand the first line (var new_id = ...) and why it is needed, but what is the second line doing, and how does the id replacement work?
I am asking because in my app, when clicking "add_new_row", the new row is inserted at the top of my page, not in the table where it belongs.
Thanks for any help you can offer.