Inside my foreach loop I want to only allow a single checkbox to be selected, right now I can select multiple.I have an onchange event but this will not uncheck the other checkboxes when I make a checkbox selection. What's wrong here? Thanks
<input type="checkbox" name="Promote" data-bind="checked: Promote, event: { change: $parent.promoterSelectedOnchange }" /> Display as main editor
ConsultingEditors: KnockoutObservableArray<NavigatorAuthorApi> = ko.observableArray();
promoterSelectedOnchange = () => {
if (this.ConsultingEditors().some(e => e.Promote)) {
this.ConsultingEditors().forEach((e) => {
e.Promote = false;
});
return this.ConsultingEditors();
}
}
export type NavigatorAuthorApi =
{
SortOrder: number,
FirmRef: number,
FirmName: string,
AuthorRef: number,
AuthorName: string,
DisplayString: string,
EditorImage: ByteString[],
Promote: boolean
}
Aucun commentaire:
Enregistrer un commentaire