Jump to content
Sign in to follow this  
Xera

Fire change-event manually

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...