开发者

Including Javascripts hosted on localhost in a rails app

开发者 https://www.devze.com 2023-03-25 05:18 出处:网络
I have a page app/views/shared/_tcpsocket.html.erb and am trying to include the following two javscripts:

I have a page app/views/shared/_tcpsocket.html.erb and am trying to include the following two javscripts:

<script src = 'http://localhost:8000/static/Orbited.js' content-type='application/x-javascript'></script>

and

<script src = 'http://localhost:8000/static/protocols/xmpp/xmpp.js' content-type='application/x-javascript'></script>

But neither of them are recognised. I have checked and the addresses are valid. How do I link to thes开发者_JS百科e files? Do I need a javascript_include_tag? I always seem to struggle linking to external .js files.

Thanks.


Why are you putting spaces between the src, = and value for this attribute? Try not putting these spaces there and see what results. I believe that HTML is parsing each space-separated value as its own attribute.


Try to put this on the head.

<%= javascript_include_tag 'static/Orbited.js','static/protocols/xmpp/xmpp.js' %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号