简体   繁体   English

将外部js文件加载到引导模式框中

[英]load external js file into bootstrap modal box

I need to show google map in bootstrap modal box. 我需要在引导模态框中显示google map。 I load google map API from google site in my page and modal box worked. 我在页面中从Google网站加载了Google Map API,并且模式框正常工作。 Like This : 像这样 :

<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=places"></script>

HTML : HTML:

<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a>

Now, I need to load google map api( .JS File / Libraries ) from url after click link (launch Modal) of modal box. 现在,我需要在模式框的链接(启动模态)单击后从URL加载google map api( .JS File / Libraries )。 How to create this ? 如何创建呢?

If you're using jQuery, then you could use the jQuery.getScript() method: http://api.jquery.com/jquery.getscript/ 如果您使用的是jQuery,则可以使用jQuery.getScript()方法: http : jQuery.getScript()

Basic usage: 基本用法:

$.getScript( "ajax/test.js", function( data, textStatus, jqxhr ) {
  console.log( data ); // Data returned
  console.log( textStatus ); // Success
  console.log( jqxhr.status ); // 200
  console.log( "Load was performed." );
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM