[Solved] TypeError: this.$q.dialog(...).then is not a function



  • Trying to use the Dialog plugin. Installed the plugin in quasar.conf.js as explained in the doc:
    framework: {
    plugins: [‘Dialog’]
    }

    Tried with a simple example:

    this.$q.dialog({
    title: ‘Confirm’,
    message: ‘Do you want to save this session?’,
    ok: true,
    cancel: true,
    }).then(() => {
    this.$q.notify(‘Agreed!’)
    }).catch(() => {
    this.$q.notify(‘Disagreed…’)
    })

    I did get the dialog popup. But in the development console, I keep getting 2 error messages:

    [Vue warn]: Error in v-on handler: "TypeError: this.$q.dialog(…).then is not a function"

    found in

    —> <QBtn>
    <QPage>
    <PageIndex> at src/pages/Index.vue
    <QPageContainer>
    <QLayout>
    <MyLayout> at src/layouts/MyLayout.vue
    <App> at src/App.vue
    <Root>

    TypeError: this.$q.dialog(…).then is not a function

    Did I miss something? I’m using quasar - 1.5.1.

    Thanks



  • I just realized that I was reading the older version documentation 0.17.20 instead of the latest. Going to try out the new onOK() chain method instead of the .then()



  • SOLVED.
    Need to use:
    this.$q.dialog({
    title: ‘Confirm’,
    message: ‘Do you want to save this session?’,
    ok: true,
    cancel: true,
    }).onOk(() => {})

    instead of

    this.$q.dialog({
    title: ‘Confirm’,
    message: ‘Do you want to save this session?’,
    ok: true,
    cancel: true,
    }).then(() => {})


Log in to reply