Hey there, I'm facing an issue with manually triggering a change event.
Currently, I have a selectOneMenu (similar to a dropdown in JSF) with various values.
When I select a value from this dropdown list, a datatable is supposed to be updated. This works as expected when I manually choose a value.
However, there's a scenario where I need to add a new value to the selectOneMenu. While this new value gets automatically selected, the change event required to update the datatable doesn't get triggered...
Essentially, I have a button to save a new value to the selectOneMenu, which then gets selected correctly. But the datatable does not update, prompting me to create the function fireChange() and assigning it to the oncomplete attribute of the button:
<p:commandButton ajax="true" id="seatingPlanSave" actionListener="#{EventAssistentController.createSeatingPlan}" value="#{msg.save}" update=":createEvent:EventSeatingPlan, :createEvent:ticketTypePrices" oncomplete="fireChange()"/>
I've attempted various implementations for the fireChange() function:
function fireChange() {
var element = document.getElementById("createEvent:EventSeatingPlan_input");
element.change();
}
function fireChange() {
var element = document.getElementById("createEvent:EventSeatingPlan_input");
$(element).trigger("change");
}
function fireChange() {
if ("fireEvent" in element)
element.fireEvent("onchange");
else {
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
element.dispatchEvent(evt);
}
}
Unfortunately, none of these solutions seem to work. Could you please provide guidance on how I can achieve this?
Thank you, Xera