admin管理员组文章数量:1421031
I would like to prevent triggering the onchange event of selectbooleancheckbox when its value is toggled in toggleBillableChkBox method.
<p:selectBooleanCheckbox value="#{myBean.billableBoolean}" widgetVar="billableEditVar"
id="billableEdit" onchange="showBillableForEdit(this)">
</p:selectBooleanCheckbox>
function showBillableForEdit(obj){
if(obj.checked){
confirmBillableYesEdit.show();
} else{
confirmBillableNoEdit.show();
}
}
<p:confirmDialog id="confirmBYesEditId" header="Please Confirm" severity="alert" visible="false"
widgetVar="confirmBillableYesEdit"
message="edit Are you sure you want to invoice this service ?" >
<p:mandButton value="Yes" onplete="confirmBillableYesEdit.hide();" global="false" >
</p:mandButton>
<p:mandButton value="No" onclick="toggleBillableChkBox();"
onplete="confirmBillableYesEdit.hide();">
</p:mandButton>
</p:confirmDialog>
function toggleBillableChkBox() {
billableEditVar.toggle();
}
I would like to prevent triggering the onchange event of selectbooleancheckbox when its value is toggled in toggleBillableChkBox method.
<p:selectBooleanCheckbox value="#{myBean.billableBoolean}" widgetVar="billableEditVar"
id="billableEdit" onchange="showBillableForEdit(this)">
</p:selectBooleanCheckbox>
function showBillableForEdit(obj){
if(obj.checked){
confirmBillableYesEdit.show();
} else{
confirmBillableNoEdit.show();
}
}
<p:confirmDialog id="confirmBYesEditId" header="Please Confirm" severity="alert" visible="false"
widgetVar="confirmBillableYesEdit"
message="edit Are you sure you want to invoice this service ?" >
<p:mandButton value="Yes" onplete="confirmBillableYesEdit.hide();" global="false" >
</p:mandButton>
<p:mandButton value="No" onclick="toggleBillableChkBox();"
onplete="confirmBillableYesEdit.hide();">
</p:mandButton>
</p:confirmDialog>
function toggleBillableChkBox() {
billableEditVar.toggle();
}
Share
Improve this question
asked Nov 11, 2014 at 15:41
meheremehere
1,5565 gold badges29 silver badges53 bronze badges
2 Answers
Reset to default 1You can't prevent the event from firing that I know of but you can stop it from doing anything with this code. (this replaces your onclick
) in a script tag:
$('#billableEdit').on('change', function( evt ) {
evt.preventDefault();
evt.stopPropagation();
billableEditVar.toggle();
});
return false didnot work for me..so i just cleared the onchange of the element just before toggling.
function toggleBillableChkBox() {
document.getElementById('billableEdit_input').onchange = "";
billableEditVar.toggle();
}
本文标签: javascriptPrevent calling onchange event when checkbox value changesStack Overflow
版权声明:本文标题:javascript - Prevent calling onchange event when checkbox value changes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745338376a2654148.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论