Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.$noty.button / VueNoty.button is not a function #1

Open
nateritter opened this issue Dec 8, 2017 · 7 comments
Open

this.$noty.button / VueNoty.button is not a function #1

nateritter opened this issue Dec 8, 2017 · 7 comments

Comments

@nateritter
Copy link

nateritter commented Dec 8, 2017

I'm attempting to add confirmation buttons to the dialog per https://ned.im/noty/#/confirm. When I try either ...

this.$noty.button('YES', 'btn', function () { console.debug('foo'); })

or

VueNoty.button('YES', 'btn', function () { console.debug('foo'); })

... and attempt to add it to the message's buttons property, I get the following error:

TypeError: this.$noty.button is not a function

@nateritter
Copy link
Author

Similarly, this.$noty.closeAll is not a function when trying to this.$noty.closeAll();

@stranger26
Copy link
Contributor

@nateritter I dont think .button is a supported feature in this wrapper at the moment.

@nateritter
Copy link
Author

@stranger26 Yes, I see that. I guess I should have edited this to be more of a request after I found it. I'd like buttons to be supported. :)

@FnnDK
Copy link

FnnDK commented Apr 27, 2018

A simple workarround is importing Noty from 'noty' and using Noty.button instead of this.$noty.button.

Is'n the best solution, but works while this is'nt supported.

@ploissken
Copy link

Is this feature ever going to be supported? (:

@JonathanSchndr
Copy link

my workaround

import 'vuejs-noty/dist/vuejs-noty.css'
import Vue from 'vue'
import VueNoty from 'vuejs-noty'
import Noty from 'noty'

export default ({app}, inject) => {
  inject('noty', Vue.use(VueNoty, {
    timeout: 3000,
    progressBar: false,
    layout: 'topRight',
    closeWith: ['click', 'button'],
  }).noty)

  window.Noty = Noty // workaround for buttons
}

@matt6frey
Copy link

matt6frey commented Jun 17, 2022

Similar to what @FnnDK was saying, in your main.js, you could probably extend/add that function to noty similar to how you would extend a prototype or object in JS. Perhaps something like:

/*
 Other Main.js imports
*/
import Noty from 'noty'
import VueNoty from 'vuejs-noty'

VueNoty.button = Noty.button

Vue.use(VueNoty)

// continue with app initialization

Note I haven't tested this but it seems like something that would be possible. There may be a little more involvement. Might look into this later tonight 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants