I will change the value of an input field with this in the console:
document.getElementById("repository-path").value = "/content/*/americas/us/en/";
and when the value has changed, it should direct me to the page in the CMS tree.
But without pressing enter it doesn't open the tree.
So I'm wondering if I can fire an enter keyboard event with vanilla javascript so that without pressing enter the input value should open automatically.
I tried this :
var evt = new KeyboardEvent("keydown", { bubbles: true, cancelable: true, keyCode: 13 }); element.dispatchEvent(evt);
but it didn't work for me.
I'm not good with programming, just want to optimize content editing time for myself.
Thanks.
CodePudding user response:
you can simulate the keypress in javascript:
const event = new KeyboardEvent('keydown', {'keyCode':13, 'which':13});
input.dispatchEvent(event);