Question

I need to catch the click (or hide) event of a alertify.js event. I set up the time to 0 in order to wait to the user for click in the message. Is there any way to attach a function to this event?

<link rel="stylesheet" href="alertify.js-0.3.11/themes/alertify.core.css" />
<link rel="stylesheet" href="jalertify.js-0.3.11/themes/alertify.default.css" id="toggleCSS" />
<script src="alertify.js-0.3.11/lib/alertify.min.js"></script>

<script>
    alertify.log('test','',0);
</script>
Was it helpful?

Solution

You can attach an event to the document, and see if the element clicked on has a class that matches the class names attached to alertify logs (alertify-log).

For example, you could use code like this:

document.body.addEventListener('click', function (e) {
  if(e.target.className.indexOf('alertify-log') > -1) {
    console.log('Clicked on a log');
  }
}, false);

Demo

OTHER TIPS

Try

alertify.log('test',function(){
    //function here
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top