Concrete5-8.4 jQuery PNotify Uncaught ReferenceError: PNotify is not defined

1.4k views Asked by At

I show a PNotify tooltip on mouseover element:

$(document).ready(function(){
    $('.element1').on('mouseover', '.element2', function(e) {
        if (PNotify.notices.length > 0) {
            PNotify.removeAll();
        }
        var tooltip = new PNotify({
            text: pin_text,
            ...

It works only if I'm logged in. The tooltip does not pop up and it throws an error: "Uncaught ReferenceError: PNotify is not defined" without being logged in. As soon as I login, it starts working without error.

Looks like PNotify in C5 is only available to logged in users by default. How can I use it in the view?

I tried changing

var tooltip = new PNotify({

to

tooltip = ConcreteAlert.notify({

Now it says "Uncaught ReferenceError: ConcreteAlert is not defined".

If I use the following in the controller:

$al = \Concrete\Core\Asset\AssetList::getInstance();
$al->register('javascript', 'pnotify', 'js/build/vendor/pnotify/pnotify.js');
$this->requireAsset('javascript', 'pnotify');

it screws all my css design and simply appends the hints at the bottom of the page.

0

There are 0 answers