29.09.2021, 11:11
(29.09.2021, 10:36)admin Wrote: If you reference $('.alert') further in the code this means that all elements with alert class will be flashed if at least one objects is set to true. So it won't work for multiple/different alert objects. Try this (not tested):
Code:$(function() { $('.alert').each(function(_, el) { var $el = $(el); var addr = $el.data('object'); var timer; if (addr) { grp.listen(addr, function(obj) { if (obj.value) { if (!timer) { timer = setInterval(function() { $el.toggleClass('hide'); }, 500); } } else { $el.removeClass('hide'); clearInterval(timer); timer = null; } }); } }); });
That's right, I didn't notice that because I tested it on one object
your script seems to work fine, I tested it for two objects and work fine
Best Regards,