+import {createApp} from 'vue';
+import DialogService from 'primevue/dialogservice';
+
+const app = createApp(App);
+app.use(DialogService);
+
+
+
+
+import DynamicDialog from 'primevue/dynamicdialog';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/dynamicdialog/dynamicdialog.min.js"></script>
+
+
+
+ $dialog is available as a property in the application instance.
+
+export default {
+ methods:{
+ onShow() {
+ const dialogRef = this.$dialog.open(ProductListDemo, {
+ props: {
+ header: 'Product List',
+ style: {
+ width: '50%',
+ height: '550px',
+ },
+ modal: true
+ },
+ templates: {
+ footer: () => {
+ return [
+ h(Button, { label: "No", icon: "pi pi-times", onClick: () => dialogRef.hide({ buttonType: 'No' }), class: "p-button-text" }),
+ h(Button, { label: "Yes", icon: "pi pi-check", onClick: () => dialogRef.hide({ buttonType: 'Yes' }), autofocus: true })
+ ]
+ }
+ },
+ onHide: (options) => {
+ const data = options.data;
+ if (data) {
+ const buttonType = data.buttonType;
+ const summary_and_detail = buttonType ? { summary: 'No Product Selected', detail: `Pressed '${buttonType}' button` } : { summary: 'Product Selected', detail: data.name };
+
+ this.$toast.add({ severity:'info', ...summary_and_detail, life: 3000 });
+ }
+ }
+ });
+ }
+ }
+}
+
+
+
+ The dialog instance can be injected with the useDialog function.
+
+import { defineComponent } from "vue";
+import { useDialog } from "primevue/usedialog";
+
+export default defineComponent({
+ setup() {
+ const dialog = useDialog();
+ const dialogRef = dialog.open(ProductListDemo, {
+ props: {
+ header: 'Product List',
+ style: {
+ width: '50%',
+ height: '550px',
+ },
+ modal: true
+ },
+ templates: {
+ footer: () => {
+ return [
+ h(Button, { label: "No", icon: "pi pi-times", onClick: () => dialogRef.hide({ buttonType: 'No' }), class: "p-button-text" }),
+ h(Button, { label: "Yes", icon: "pi pi-check", onClick: () => dialogRef.hide({ buttonType: 'Yes' }), autofocus: true })
+ ]
+ }
+ },
+ onHide: (options) => {
+ const data = options.data;
+ if (data) {
+ const buttonType = data.buttonType;
+ const summary_and_detail = buttonType ? { summary: 'No Product Selected', detail: `Pressed '${buttonType}' button` } : { summary: 'Product Selected', detail: data.name };
+
+ this.$toast.add({ severity:'info', ...summary_and_detail, life: 3000 });
+ }
+ }
+ })
+ }
+})
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
props | +object | +null | ++ |
templates | +object | +null | ++ |
onHide | +function | +null | +Close function of the dialog. | +
Name | +Parameters | +Description | +
---|---|---|
open | +content: The component to load + options: configuration of the Dialog + |
+ Creates the dialog. | +