2012-06-02 66 views
0

我使用基因敲除2驗證庫[Knockout Validation] [1]。儘管UI對對象數組內部的可觀察屬性正確顯示驗證錯誤。 ko.validation.group函數不會跟蹤這些錯誤。看看源代碼,我發現它只能檢查數組對象本身的可觀察性,而不是內部可觀察的屬性。陣列對象內可觀察對象的基因敲除驗證錯誤

我有這些

function Game(bowlerId, name, g1, g2, g3, g4) { 
    this.BowlerId = bowlerId; 
    this.Name = name; 
    this.Game1 = ko.observable(g1).extend({ required: true, min:1, max:300 }); 
    this.Game2 = ko.observable(g2).extend({ required: true, min: 1, max: 300 }); 
    this.Game3 = ko.observable(g3).extend({ required: true, min: 1, max: 300 }); 
    this.Game4 = ko.observable(g4).extend({ required: true, min: 1, max: 300 }); 

} 

,我使用像的數組:

viewModel.errors = ko.validation.group(viewModel.Games); 

或類似

viewModel.errors = ko.validation.group(viewModel); 

在任一情況下的各特性(的Game1,GAME2等),以上不在由組函數返回的錯誤中進行跟蹤。儘管驗證錯誤確實出現在UI中。目前我必須查詢DOM以查看用戶是否提出了驗證錯誤。有什麼方法可以讓這個工作?

回答

0

你有沒有試過?

viewModel.errors = ko.validation.group(viewModel.Games, { deep: true }); 
+0

我放棄了淘汰賽,因爲這個問題,將永遠不會再使用具有對其他庫(不支持)的核心依賴的框架。驗證非常關鍵,它必須是基礎框架的一部分,並且受到基礎框架的支持。我現在是一個非常開心的AngularJS用戶。感謝你的努力。 – Pablo

相關問題