No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to set default config for Dialog plugin?

    Framework
    3
    3
    288
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      chrislandeza last edited by

      I’ve created a custom Dialog Component to be invoked like this:

      // Inside Vue file
      import CustomComponent from '..path.to.component..'
      
      this.$q.dialog({
        component: CustomComponent
      })
      

      but I don’t want to import CustomComponent every time I use this.$q.dialog() on my Vue files. It would be nice if Dialog plugin also have a setDefaults() method where I can set default configurations:

      // src/boot/dialog-default.js 
      import { Dialog} from 'quasar'
      import CustomComponent from '..path.to.component..'
      
      Dialog.setDefaults({
         component: CustomComponent
      })
      

      Is there a workaround for this?

      1 Reply Last reply Reply Quote 0
      • Allan-EN-GB
        Allan-EN-GB Admin last edited by

        I thought you could set defaults for this in Quasar.conf.js but after looking, it seems you can’t so this is another way 🙂

        Just create a showDialog method in a mixin and make it a global one. You can then call showDialog wherever you need to and pass through optional options using destructuring to merge them,

        i.e.

        showDialog (options) {
          this.$q.dialog({
            component: CustomComponent,
            ...options
          })
        }
        
        1 Reply Last reply Reply Quote 0
        • W
          walfin last edited by

          Bumping this. Hoping that this functionality can be added. It doesn’t make sense that we can set defaults for loading, but not dialog.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post