如何在添加前檢查重複簽名。在下面的場景中,如果沒有簽名找到列表,我想添加簽名。使用ko.observableArray檢查重複
var Signature = function (name, interestDeclared) {
this.Name = ko.observable(name);
this.RelevantInterest = ko.observable(interestDeclared);
}
viewModel = {
signatures: ko.observableArray([]),
addSignature: function() {
var name = $('#signatureName').val();
var intd = $('#interest').is(':checked');
this.signatures.push(new Signature(name, intd));
},
deleteSignature: function (signature) {
this.signatures.remove(signature);
},
insertWitness: function (signature, position) {
this.signatures.splice(position, 0, signature);
}
};
ko.applyBindings(viewModel, document.getElementById("signatories"));
感謝, -Naren