How can I check the duplicate signatures before adding. In the below scenario, I wanted add signature if no signature found the list.
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"));
Thanks,
-Naren
Using jQuery’s grep function: