[英]Checked event doesn't work correctly in firefox
Below code works fine in all browsers except Firefox. 以下代码在Firefox以外的所有浏览器中均能正常运行。
On first click on the checkbox it displays the correct value but in Firefox, it only shows correct value after check box is checked second time. 第一次单击该复选框时,它显示正确的值,但是在Firefox中,它仅在第二次选中该复选框后才显示正确的值。
If I change checked: checked
to checked: checked()
then after the first click it shows the correct value in Firefox but then enable:
doesn't work and it doesn't enable field. 如果更改为
checked: checked
到checked: checked()
则在第一次单击后,它将在Firefox中显示正确的值,但随后enable:
不起作用,并且不启用字段。
<input type="checkbox"
data-bind="attr: { id: eId, title: description },
checked: checked,
enable: $root.enableInput,
event: { change: function (newValue) { if (!newValue.checked()) { var TotalValue = !Helper.IsUndefinedOrNull($parent.totalValue()) ? Number($parent.totalValue().toString().replace(/[^0-9\.]+/g, '')) : 0; chargeTypeName() == 'Percentage' ? testChargeAmount(chargeAmountValue() * totalValue) : testChargeAmount(chargeAmountValue()); } } }" />
<label data-bind="text: displayText, attr: { 'for': eId, title: description }"></label>
<input type="text" class="input_text currency"
data-bind="value: testChargeAmount, precision: 2, attr: { title: description },
enable: checked(), css: { eAmountDisabled: !checked()} " />
<input type="text" class="input_text exceptionText"
data-bind="value: exceptionText,
enable: (checked() && $root.enableInput)" />
The event
binding will cancel the default action of the event. event
绑定将取消event
的默认操作。 If you don't want to cancel the default action, you must return true
from the handler function: 如果您不想取消默认操作,则必须从处理程序函数
return true
:
event: {
change: function() {
....
return true;
}
}
Reference: http://knockoutjs.com/documentation/event-binding.html#note-3-allowing-the-default-action 参考: http : //knockoutjs.com/documentation/event-binding.html#note-3-allowing-the-default-action
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.