Hi, I have a frontend form that consists of a bunch of fields, and I need to be able to set the value of the field with JS using a chrome add-on.
I managed to get the regular text/number fields working properly using $('#field_id').val(new_value);, however I am having a hard time setting the value of the Taxonomy Advanced field and the WYSIWYG fields.
The Taxonomy Advanced field uses the Select2 library, and based on their docs, I should be able to set the field value using $('#field_id').val(value).trigger('change'); (for value i'm using the taxonomy ID) but it is not working for some reason.
Can you please give me some direction on how to complete this task?
But please notice that it helps you to set the value for the available options in the DOM. While the field type select_advanced (select2) supports searching the other terms (options) via AJAX which are not available in the DOM.
Thank you. I realized the code does select the correct item (I'm not using ajax), however it doesn't show the selected item in the box. It still shows the placeholder. Only after I click the drop-down does it show that it's selected...
Also, can you please share a method on how to set the value of the WYSIWYG field?