pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)
Res facta quae tamen fingi potuit ([personal profile] pauamma) wrote in [site community profile] dw_dev2018-03-18 08:25 pm
Entry tags:

Question thread #62

It's time for another question thread!

The rules:

- You may ask any dev-related question you have in a comment. (It doesn't even need to be about Dreamwidth, although if it involves a language/library/framework/database Dreamwidth doesn't use, you will probably get answers pointing that out and suggesting a better place to ask.)
- You may also answer any question, using the guidelines given in To Answer, Or Not To Answer and in this comment thread.
bytebuster: (Keaton-NoSmile)

[personal profile] bytebuster 2018-03-28 11:55 am (UTC)(link)
Thank you for the answer, this is what I was afraid of. :)

Yes, my goal is to pre-populate the form so that it remains to only press the "Post" button. I tried to direct populate the fields that are submitted along with the form, but:

1. this would not display on screen
2. if you simply press "Post" button, some fields (Tags and something else, don't remember for sure) is not posted to the server upon the form submission.
bytebuster: (Keaton-Greeting)

[personal profile] bytebuster 2018-03-30 12:33 pm (UTC)(link)
Wow, that was easy. Dispatching a 'change' event works for all three JS-rich elements: To-Community dropdown (after setting its .selected), Icon dropdown, and Tags string input (after setting its .value).
Here's how to do it for Tags:

const CLS_INPUT_TAGS = "autocomplete-input";
elTags = document.getElementsByClassName(CLS_INPUT_TAGS)[0];
elTags.value = "tag1, tag2";
elTags.dispatchEvent(new Event('change'));
Edited 2018-03-30 12:33 (UTC)