code: function (elements, index, toReplace, replaceWith) {
  
              var replaceAttrDataNode = function (node) {
                  var jqNode = $(node);
                  if (typeof node === 'object' && 'attributes' in node) {
                      $.each(node.attributes, function (i, attrib) {
                          if ($.type(attrib.value) === 'string') {
                              jqNode.attr(attrib.name.replace(toReplace, replaceWith), attrib.value.replace(toReplace, replaceWith));
                          }
                      });
                  }
                  if (jqNode.length > 0) {
                      $.each(jqNode.data(), function (name, value) {
                          if ($.type(value) === 'string') {
                              jqNode.data(name.replace(toReplace, replaceWith), value.replace(toReplace, replaceWith));
                          }
                      });
                  }
              };
  
              var element = elements.eq(index);
              replaceAttrDataNode(element[0]);
              element.find('*').each(function () {
                  replaceAttrDataNode(this);
              });
          }
docs: if we need to change CollectionType_field_42_value to CollectionType_field_84_value, this method will change it in id="CollectionType_field_42_value", but also data-id="CollectionType_field_42_value" or anywhere else just in case it could be used otherwise.