[英]Checked event doesn't work correctly in firefox
以下代碼在Firefox以外的所有瀏覽器中均能正常運行。
第一次單擊該復選框時,它顯示正確的值,但是在Firefox中,它僅在第二次選中該復選框后才顯示正確的值。
如果更改為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)" />
event
綁定將取消event
的默認操作。 如果您不想取消默認操作,則必須從處理程序函數return true
:
event: {
change: function() {
....
return true;
}
}
參考: http : //knockoutjs.com/documentation/event-binding.html#note-3-allowing-the-default-action
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.