$('.cooperative-alert-container').html('<%= j( render partial: 'shared/alert', locals: { message: message } ) %>'); setTimeout(function() { if ($('.cooperative-alert-container button.close').length > 0) { $('.cooperative-alert-container button.close').trigger('click'); } }, 5000) $(".cooperative-body-container").animate({ scrollTop: 0 }, 200);