Jump to content

Fire change-event manually


Xera

Recommended Posts

Hey I've got a problem with fireing a change-event manually.So I have a selectOneMenu (i'ts like a dropdown in jsf) with different values.If I choose a value of this dropdown-list, a datatable should be updated. This works correctly, if i choose this value manually.Now there is a case, where I need to insert a new value to the selectOneMenu. This new value gets selected automatically, but the change-event to update the datatable doesn't get fired...So basically I have this button to save a new value to the selectOneMenu which then gets selected correctly, but the datatable doesn't get updated, which is why I tried to write the function fireChange() and gave that to the oncomplete of the button:

<p:commandButton ajax="true" id="seatingPlanSave" actionListener="#{EventAssistentController.createSeatingPlan}" value="#{msg.save}" update=":createEvent:EventSeatingPlan, :createEvent:ticketTypePrices"oncomplete="fireChange()"/>

For the fireChange()-function, i tried a few different things:

function fireChange() {    var element = document.getElementById("createEvent:EventSeatingPlan_input");element.onchange();}

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);}

But none of these work :(Can you please tell me how I can achieve this?Thanks, Xera

Link to comment
Share on other sites

You might be able to find information about that in the documentation for whatever you're using, or you can also send that element to the browser's developer console and then inspect it to see what methods are available. One issue is passing the correct parameters to the event handler, so you'll probably need to look up the documentation.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...