[英]How do I include jQuery/bootstrap/javascript in my rails app with a CDN?
I know you can add jQuery and bootstrap with gems, assets, and the application.css and application.js file. 我知道你可以使用gems,assets以及application.css和application.js文件添加jQuery和bootstrap。 However, I would like to be able to add these files through a CDN.
但是,我希望能够通过CDN添加这些文件。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
I have added the above into my application.html.erb file, but I seem to not be able to use bootstrap or jQuery still. 我已将上述内容添加到我的application.html.erb文件中,但我似乎无法使用bootstrap或jQuery。 Can you please explain why rails doesn't allow linking in the html file?
你能解释一下为什么rails不允许在html文件中链接吗? Why must we use gems?
我们为什么要使用宝石?
您还需要在结束体标记之前添加js文件:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
I guess you have to make sure you call your Jquery before your bootstrap files 我想你必须确保在引导程序文件之前调用你的Jquery
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
If you want to do a cdn call back for both Jquery and Bootstrap these are the links: stackoverflow - Bootstrap cdn callback and stackoverflow - Jquery cdn callback 如果你想为Jquery和Bootstrap做一个cdn回调,这些是链接: stackoverflow - Bootstrap cdn回调和stackoverflow - Jquery cdn回调
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.