pnotify icon indicating copy to clipboard operation
pnotify copied to clipboard

Using with WebpackEncore

Open itokia opened this issue 7 years ago • 2 comments

Hello, I would like to install PNotify in my symfony 4 project with webpackEncore. When I test a notification I get the error message PNotify is not defined.

My Webpack config :

.createSharedEntry('vendor', [
        'jquery',
        'jquery-ui/ui/effects/effect-slide',
        'bootstrap',
        'popper.js',
        'bootstrap-datepicker/dist/locales/bootstrap-datepicker.fr.min.js',
        'pnotify/dist/es/PNotify.js',
        './assets/js/base.js',
        './assets/css/app.scss'
    ])
new PNotify({
        title: "PNotify",
        type: "info",
        text: "Welcome. Try hovering over me. You can click things behind me, because I'm non-blocking.",
        nonblock: {
            nonblock: true
        },
        addclass: 'dark',
        styling: 'bootstrap4',
        hide: false,
        before_close: function(PNotify) {
            PNotify.update({
                title: PNotify.options.title + " - Enjoy your Stay",
                before_close: null
            });

            PNotify.queueRemove();

            return false;
        }
    });

itokia avatar Nov 29 '18 13:11 itokia

I can see three problems here.

  • You're trying to load the ES5 module version of PNotify. I don't think that's what you want. You probably want the IIFE version, if you're not using ES5 imports throughout your project.
  • You're including PNotify 4, but you're using the PNotify 3 API. If you have to use the PNotify 3 API for some reason, you should use the PNotifyCompat module. Otherwise, switch to the PNotify 4 API.
  • You're trying to use modules without loading them. 'nonblock' and 'before_close' are module options, but you're only loading the core PNotify script.

hperrin avatar Dec 05 '18 20:12 hperrin

Please read the README.md file for information on how to install PNotify.

hperrin avatar Dec 05 '18 20:12 hperrin