Yii2 renderAjax from Modal issue

Hello together,

I am using a bootstrap modal window shown after button click and the content is loaded via renderAjax from a view. However, when I simply try to put <script>Alert(‘test’)</script> to the view, alert doesn’t show for the first time. When I press the button another times, alert works. Any ideas?