开发者

how to provide jQuery support in Sinatra?

I have very simple sinatra application up and running. Now I want to use jsTree (jQuery plugin) in my sinatra applicat开发者_JAVA技巧ion.

I do not know how I provide the jQuery support in sinatra. Where I put the files and then how would the <script src="/path/to/jstree.js"></script> look like?


This looks relevant: https://github.com/ezgraphs/jquery-sinatra-demo.

It seems as if you need to create a /public/ folder and put jQuery into there. And from your index.html file, just reference it as if it resided in the same directory as the index.html file:

<script type="text/javascript" src="jquery-latest.js"></script>


The quickest solution is to simply paste the CDN into your view file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">

    <title></title>

    <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
  </head>

  <body>
  </body>
</html>

As per: https://jquery.com/download/#using-jquery-with-a-cdn

This is what I did and it worked no problem with my Sinatra app.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜