carlsednaoui / ouibounce

Increase your landing page conversion rates.
MIT License
2.31k stars 372 forks source link

Using without passing element doesn't work #135

Open hackuun opened 7 years ago

hackuun commented 7 years ago

Hi. I was following your guides. This doesn't work.

var _ouibounce = ouibounce(false, {
  callback: function() { console.log('ouibounce fired!'); }
})

How to use this library without ouibounce-modal id?

sebkolind commented 6 years ago

Hello

When you use Ouibounce with first parameter as false you have to do your logic in the callback function. Like for me, in Angularjs (1.x) I do something like this:

function link(scope, el, attrs, ctrl): void {
    /**
    * Passing "false" as first argument allows
    * us to use the plugin without setting it on an element,
    * and instead use the callback function to do our thing.
    */
    $window.ouibounce(false, {
        callback: () => {
            ctrl.show = !ctrl.show;
            scope.$apply();
        }
    });
}

Do you see "ouibounce fired!" in your console with your example?