Skip to content

Instantly share code, notes, and snippets.

@madprog
Created July 16, 2021 10:09
Show Gist options
  • Save madprog/63b61d8d920b2e97036eba6bad10aa62 to your computer and use it in GitHub Desktop.
Save madprog/63b61d8d920b2e97036eba6bad10aa62 to your computer and use it in GitHub Desktop.
odoo.define('openerp_enterprise.BootstrapDialog', function (require) {
'use strict';
const {
Component,
hooks: { useRef },
misc: { Portal },
} = owl;
class BootstrapDialog extends Component {
static components = { Portal };
modal = useRef("modal");
mounted() {
super.mounted();
$(this.modal.el)
.on("hidden.bs.modal", (event) => {
event.stopPropagation();
this.trigger("dialog-close");
})
.modal("show");
}
willUnmount() {
$(this.modal.el).modal("dispose");
super.willUnmount();
}
}
return BootstrapDialog;
});
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="BootstrapDialog" owl="1">
<Portal target="'body'">
<div class="modal fade d-block" t-ref="modal" tabindex="-1" role="dialog" aria-hidden="false" aria-labelledby="">
<t t-slot="default"/>
</div>
</Portal>
</t>
</templates>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment