juliancwirko / meteor-s-alert

Simple and fancy notifications for Meteor
https://atmospherejs.com/juliancwirko/s-alert
190 stars 24 forks source link

Click events on alert - Not working #37

Closed amnevins closed 9 years ago

amnevins commented 9 years ago

This is a great alerts package, to anyone considering using it.
My problem is: It seems when I use html markup in the alert as so e.g.

sAlert.info(secretMessage.Name + '<_br> <_a class="mapClick">View Profile<*/a>', {html: true});

ignore asterik in </a> and add a click listener

e.g.

'click .mapClick' : function(e) { e.preventDefault(); console.log("clicked"); }

I can't get the event to fire. Is there a way to target the sAlert for an event? I have tried using various inherited classes such as 'click .s-alert-box' , and have been unsuccessful.

Any help is appreciated, thanks!

juliancwirko commented 9 years ago

Hi, I'll test it tomorrow. I'll keep you posted here.

juliancwirko commented 9 years ago

Ok, so I have tested it and it works for me. I have:

<body>
    {{> sAlert}}
</body>
Template.sAlert.events({
    'click .alert-click-class': function (e) {
        e.preventDefault();
        console.log('Alert link clicked!');
    }
});

and I am calling for example this:

sAlert.warning('<a href="#" class="alert-click-class">Click me!</a>', {html: true, timeout: 'none'});

Let me know if this helps.

amnevins commented 9 years ago

Thanks for your response! I was not including {{>sAlert}} in my html. The alerts were still showing but HTML classes were not firing events. This is fixed now! Thanks for the awesome work!