Skip to content

Commit

Permalink
Fix clone attributes to match attributes properly when attribute name…
Browse files Browse the repository at this point in the history
… contains a period.
  • Loading branch information
jon-ide committed Sep 30, 2024
1 parent b5fc6de commit db4b895
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webapp/views/data_tables/templates/clone_attributes_4.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@
function select_default(_select_id) {
// We need to replace spaces with underscores in the SELECT id for jQuery to work properly
let select_id = _select_id.replace(/ /g, '_');
let selector = '#' + select_id + ' option';
// Get rid of SELECT__ and __SELECT substrings
let default_val = select_id.substring(8, select_id.length - 8);
// jQuery interprets '.' as a class selector, so we need to escape '.' with '\\'
// It's a double backslash because the first backslash is an escape character in a string. I.e., we're
// saying we want the backslash to go into the string, not be interpreted as an escape character.
// Now the selector will correctly find the option with the value that has a period in it.
select_id = select_id.replace(/\./g, '\\.');
let selector = '#' + select_id + ' option';
$(selector).filter(function() {
let this_text = $(this).text().replace(/ /g, '_');
return this_text === default_val;
Expand Down

0 comments on commit db4b895

Please sign in to comment.