Reputation: 55
My Js Code has set an onclick
on a component class inside a selectOneMenu
, whenever I use <p:ajax>
inside my selectOneMenu, the script runs only once.
how to prevent that?
<p:selectOneMenu id="GaStructNode_listForm_GaStruct"
value="#{gaStructNodeController.selectedGaStruct}"
style="margin-bottom: 10px;">
<f:selectItem itemLabel="#{bundle.defautlItem}"/>
<f:selectItems value="#{gaStructNodeController.findAllGaStructs()}" var="gs"
itemLabel="#{gs.name}" itemValue="#{gs}"/>
<p:ajax event="itemSelect" update="@form :GaStructNode_listForm :GaStructNode_editForm :GaStructNode_picklist_form"/>
</p:selectOneMenu>
<script type="text/javascript">
$('.ui-selectonemenu-item-group').click(function () {
alert("Handler for .click() called.");
});
</script>
Upvotes: 0
Views: 172
Reputation:
put your script inside a function and call it form the oncomplete of the p:ajax
<script type="text/javascript">
$('.ui-selectonemenu-item-group').click(function () {
alert("Handler for .click() called.");
});
function m() {
$('.ui-selectonemenu-item-group').click(function () {
alert("Handler for .click() called.");
});
}
</script>
and change your ajax:
<p:ajax oncomplete="m()" event="itemSelect" update="@form :GaStructNode_listForm :GaStructNode_editForm :GaStructNode_picklist_form"/>
Upvotes: 1