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 close all notifications in v 1.9.12?

    Framework
    2
    2
    217
    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.
    • A
      alex.kulkoff last edited by

      Hi. I have action from vuex:

      setError (payload) {
            this.$q.notify({
              type: 'negative',
              message: payload.message,
              timeout: 0,
              actions: [
                { label: 'Close', color: 'white', handler: () => { /* ... */ } }
              ]
            })
          }
      

      What action can I create to close this notification?

      dismissAllNotifications () {
      /// ????
      }
      
      1 Reply Last reply Reply Quote 0
      • T
        tof06 last edited by

        @alex-kulkoff You said you are calling notify from a vuex action (at least, this is what I understood πŸ™‚ ). So, you can’t use this.$q.notify afaik. You have to import { Notify} from 'quasar' and then call Notify.create.

        Anyway, both way will return a dismiss function you can store somewhere.

        If you are in a vuex action, for ex :

        // VuexState
        return {
          notifications: []
          // ...
        }
        
        // Vuex Action
        import { Notify} from 'quasar'
        
        setError ({state, commit}, payload) {
          commit('addError', Notify.create({
            type: 'negative',
            message: payload.message,
            timeout: 0,
            // ...
          })
        }
        // dismissAllErrors action
        dismissAllErrors({state, commit}) {
          state.notifications.map(dismiss => dismiss())
          commit('clearErrors')
        }
        
        // addError Mutation
        addError (state, dismiss) {
          state.notifications.push(dismiss)
        }
        
        // clearErrors Mutation
        clearErrors (state) {
          state.notifications = []
        }
        

        Did not test, but should work πŸ˜‰

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