not really but i guess you want this #node-input-options
to have the previous selection when the user re-opens the editor?
As I have said in other posts, you need to persist the selection in a node.propertyXXX upon oneditsave
then in the oneditprepare
function, when you do the fetch & populate the dropdown, use the persisted node.propertyXXX
value to re-select the item,
See a full explanation here
So for example...
data.forEach((item) =>
let value = item.name;
let text = item.name;
options.push({ v: value, t: text, });
$("#node-input-options").append(
$("<option></option>").attr("value", value).text(text)
);
if(value == node.selectedValue) $('#node-input-options').attr('selected','selected'); //<<<<<
);
node.selectedValue
is something you need to set when the select is changed.- that means you need to have an
$("#node-input-options").on("change", function(){ ...}
- and you need to add
selectedValue
to thedefaults
object