通过AJAX加载的页面中的脚本不以模态(BS4)执行

时间:2018-02-15 16:37:32

标签: javascript ajax iframe modal-dialog twitter-bootstrap-4

以下代码成功动态加载模态体内的“远程”页面(data-remote =“/ booking-app-1”)。但是,此目标页面只包含一个<脚本>它加载IFrame(用于外部支付应用程序)。此脚本不会执行。有没有办法解决这个问题,或者更好的方法是通过URL直接将预订应用程序的脚本注入模态体? 我也尝试将数据远程URL交换到我的页面,URL直接指向预订应用程序的脚本,但这不起作用。

<button type="button" class="btn" data-toggle="modal" data-target="#bookingApp-1" data-remote="/booking-app-1" >
 BUY THING 1
</button>


<!-- Modal -->
<div class="modal fade" id="bookingApp-1" tabindex="-1" role="dialog" aria-labelledby="bookingApp-1" aria-hidden="true">
  <div class="modal-dialog" role="document">
      <div class="modal-body">
         (CONTENT LOADS HERE)
      </div>
  </div>
</div>



<script> // I will have multiple modals with different scripts on the page
$('body').on('click.modal.data-api',
      '[data-toggle="modal"]', function(){ 
         $($(this).data("target")+' .modal-body').load($(this).data('remote')); });
</script>

/booking-app.php:

<script type="text/javascript" src="https://bookeo.com/widget.js?a=12345&amp;type=1234_not_the_actual_url"></script>

0 个答案:

没有答案