Closed lifeiscontent closed 4 years ago
Yes.
An example:
var showDialog = (function () {
var root = $("<div>").addClass("portal").appendTo("body"), dlg = app({
text: "Default text"
}, {
changeText: function (text) {
return { text: text };
}
}, function (state) {
return (<div class="dialog portal__dialog">
<p class="dialog__text">{state.text}</p>
<div class="dialog__buttons">
<button type="button" class="btn btn--primary" onclick={ function () {
root.trigger("ok"); } }>OK</button>
<button type="button" class="btn btn--secondary" onclick={ function () {
root.trigger("cancel"); } }>Cancel</button>
</div>
</div>);
}, root.get(0));
return function (text) {
dlg.changeText(text);
root.addClass("portal--active");
return new Promise(function (resolve, reject) {
root.on("ok", function () {
root.off("ok").off("cancel");
resolve();
}).on("cancel", function () {
root.off("ok").off("cancel");
reject();
});
});
};
})();
Wow! Thank you so much! You rock @infinnie 👍
Hi @infinnie I read your post here: https://medium.com/@joanxie/use-hyperapp-enjoy-javascript-again-ab9633f7066f
I was curious if you had a solution to dealing with displaced content within hyperapp.