UNPKG

@paperbits/core

Version:
35 lines (32 loc) 1.11 kB
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); } };