2014-10-05 73 views
0

下面的代碼在除Firefox以外的所有瀏覽器中均正常工作。檢查的事件在Firefox中無法正常工作

第一次點擊複選框會顯示正確的值,但在Firefox中,它只會在第二次選中複選框後顯示正確的值。

如果我改變checked: checkedchecked: 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)" /> 
+0

請務必包括最少但足夠代碼輕鬆攝製的問題。如果可能的話,創建一個代碼片段或小提琴來演示它。 – Jeroen 2014-10-05 20:33:34

+2

無論如何,在使用Knockout的時候,你只需要關心* change *事件。當事件在DOM中觸發時,您應該讓KO處理更改您的視圖模型值。 – Jeroen 2014-10-05 20:37:45

回答