How to lazy load dialog ?

I have multiple complex dialog on my page, which will be very slow if loaded when page load。

How to lazy load dialog ? like Dynamic Components

I have tried using the dialog template,but it did not work.

demo code:

```MainPage

<template>
  <div>
    <ejs-button @click.native="openDialog">Open Dialog</ejs-button>
    <ejs-dialog
      ref="dialogObj"
      width='500px'
      height='300px'
      v-bind:visible="false"
      :showCloseIcon="true"
      header="My Title"
      :content='templateDialog'
    ></ejs-dialog>
  </div>
</template>
<script>
import dialogTemplate from './DialogTemplate.vue';

export default {
  data: function () {
    return {
      templateDialog: function () {
        return { template: dialogTemplate };
      },
    };
  },
  methods: {
    openDialog() {
      this.$refs.dialogObj.show();
    },
  },
};
</script>

```

```DialogTemplate

<template>
  <div>
    Dialog Content
  </div>
</template>

<script>
//test lazy load dialog
export default {
  mounted() {
    console.log('DialogComponent-mounted');
  },
  methods: {},
};
</script>

```

What i want is , when the "mainpage" loads, the mounted method of the dialog is not called, it is called only when "openDialog" button is clicked (lazy load).


What should I do?

Looking forward to your reply. Thanks.


4 Replies

BS Buvana Sathasivam Syncfusion Team March 9, 2022 04:02 AM UTC

Hi Bingxueyinlian, 

Greetings from Syncfusion support. 

Query #1: “How to lazy load dialog ?” 

We have also provided build-in support for dialog utility functions with minimal code. Please see below for the documentation. 


If the above solution does not meet your requirements, can you please get back to us with more details or a video of your requirement? So, we will check and update you as soon as possible. 

Query #2: “What i want is , when the "mainpage" loads, the mounted method of the dialog is not called, it is called only when "openDialog" button is clicked (lazy load)” 
As per your shared code, you are setting the initial dialog property as false. As a result, the dialog is not rendered when the page loads and is rendered using the show public method when you click the button. If you wish to render dialog at initial load, you can set the visible property to true
  
  
Regards, 
Buvana S 




BI bingxueyinlian March 9, 2022 10:46 AM UTC

set the visible property to false,it just hides but rendered .







BS Buvana Sathasivam Syncfusion Team March 11, 2022 09:07 AM UTC

Hi Bingxueyinlian,


Currently, we are validating your reported query with high priority. We will update you with further details on or before March 14, 2022.


Regards,

Buvana S



BS Buvana Sathasivam Syncfusion Team March 15, 2022 02:40 PM UTC

Hi Bingxueyinlian, 

We have considered “Provide support on load on demand at Dialog component” as a feature request from our end and logged the report for the same and the fix will be included with any of our upcoming releases.   
 
You can now track the current status of the report, review the proposed resolution timeline, and contact us for any further inquiries through this link:  

Regards, 
Buvana S 


Loader.
Up arrow icon