- var children = elt.children(':not(.q_edit)');
- while (children.length > 0) {
- children.filter('.q_edit_label').text('Question ' + (idx + 1));
- children.children('[name*="' + old_id + '"]').each(function() {
- function replace(attr) {
- var cid = $(this).attr(attr);
- if (cid.substr(0, id.length) == old_id) {
- $(this).attr(attr, new_id + cid.substring(old_id.length, cid.length));
- }
+ fixAttrs = function(attr) {
+ elt.find('[' + attr + '^="' + old_id + '"]').each(function() {
+ var cid = $(this).attr(attr);
+ if (cid.startsWith(old_id)) {
+ $(this).attr(attr, new_id + cid.substring(old_id.length, cid.length));