@paperbits/core
Version:
Paperbits core components.
35 lines (32 loc) • 1.11 kB
text/typescript
import * as ko from "knockout";
ko.bindingHandlers["confirm"] = {
init: (element: HTMLElement, valueAccessor) => {
const observable = ko.unwrap(valueAccessor());
const message = observable.message;
const onConfirm = observable.onConfirm;
let balloon;
ko.applyBindingsToNode(element, {
balloon: {
component: {
name: "confirmation",
params: {
getMessage: async () => {
return message;
},
onConfirm: async () => {
onConfirm();
balloon.close();
},
onDecline: () => {
balloon.close();
}
}
},
onCreated: (balloonHandle) => {
balloon = balloonHandle;
},
position: "top"
}
}, null);
}
};