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

Using with WebpackEncore #349

Open
itokia opened this issue Nov 29, 2018 · 2 comments
Open

Using with WebpackEncore #349

itokia opened this issue Nov 29, 2018 · 2 comments
Assignees
Labels

Comments

@itokia
Copy link

itokia commented Nov 29, 2018

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;
        }
    });
@hperrin
Copy link
Member

hperrin commented Dec 5, 2018

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 hperrin self-assigned this Dec 5, 2018
@hperrin
Copy link
Member

hperrin commented Dec 5, 2018

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

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

No branches or pull requests

2 participants